October 2016
Intermediate to advanced
452 pages
9h 5m
English
Currently, our giftlist functionality doesn't really work. We want users to be able to create giftlists which they can then share.
Since we're using Mongoose to model data for our users, let's also put it to use to model our giftlists. Inside your models folder, create a new file called giftlist.js:
var mongoose = require('mongoose');
var giftlistSchema = mongoose.Schema({
id: String,
user_id: String,
name: String,
gifts: [{name: String}]
sharedWith [{user_id: String}]
});
module.exports = mongoose.model('Giftlist',giftlistSchema);
This model is pretty straightforward. A giftlist has an ID, a name, a list of gift objects, and a user_id field. We will populate the user_id with the ID of the user who ...
Read now
Unlock full access