I would like to create a schema where I can set a specific name for a user, for example a display name that many people can have, while also allowing people to add them based on that name. My solution is to save that name into a model with two fields, one of which is the name itself, the second one having an id that represents the number of times that name is being used currently.
var DisplayName = new Schema({
account: {
type: ObjectId,
ref: 'Account',
},
name: {
type: String,
trim: true,
required: true,
},
number: {
type: Number,
required: true,
}
});
is what I have, but I would like to be able to just say
var displayName = new DisplayName({
name: 'name',
account: req.user.id
});
displayName.save();
and it would automatically set the field for me?
via Leon Chou
No comments:
Post a Comment