im new working with mongoDB and node.js im trying to creat a relation between two models applications and contactsapp
applicationsModel
'use strict'
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const contactapp = mongoose.model('ContactApp');
const ApplicationsSchema = Schema({
application_code: String,
name: String,
comments: String,
version: String,
developer: String,
url: String,
active: Boolean,
press_package: String,
pad_file: String,
image: String,
category: [String],
contacts: [{ type: Schema.ObjectId, ref: "ContactApp" }]
});
module.exports = mongoose.model('Applications', ApplicationsSchema);
contactsappModel
'use strict'
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const ContactappSchema = Schema({
fullname: String,
avatar: String,
company: String,
jobTitle: String,
email: String,
phone: String,
sex: String,
country: String,
channel: String,
website_url: String,
linkedin_url: String,
xing_url: String,
notes: String,
active: Boolean
});
module.exports = mongoose.model('ContactApp',ContactappSchema);
but when the console give me the error Schema hasn't been registered for model "ContactApp".
via Miguel Angel Gomez
No comments:
Post a Comment