var personSchema = new Schema({
_id: {type: String, required: true},
name: {type: String, required: true},
race: String,
class: String
});
var PersonData = mongoose.model('PersonData', personSchema );
var organizationSchema = new Schema({
_id: {type: String, required: true},
name: {type: String, required: true},
category: String,
structure: String,
members: [{ type: String, ref: 'PersonData'}]
});
var OrganizationData = mongoose.model('OrganizationData', organizationSchema );
_id: {type: String, required: true},
name: {type: String, required: true},
controlledBy:{
type: String, enum: [ 'Organization', 'Individual'],
controller: { type: String, ref: 'PersonData' or 'OrganizationData'}
}
Thanks for assistance.
_id: {type: String, required: true},
name: {type: String, required: true},
controlledBy:{
kind: {type: String, enum: [ 'OrganizationData', 'IndividualData']},
controller: {type: ObjectId, refPath: 'controlledBy.kind'},
}
--
Documentation - http://mongoosejs.com/
Plugins - http://plugins.mongoosejs.com/
Bug Reports - http://github.com/learnboost/mongoose
Production Examples - http://mongoosejs.tumblr.com/
StackOverflow - http://stackoverflow.com/questions/tagged/mongoose
Google Groups - https://groups.google.com/forum/?fromgroups#!forum/mongoose-orm
Twitter - https://twitter.com/mongoosejs
IRC - #mongoosejs
---
You received this message because you are subscribed to a topic in the Google Groups "Mongoose Node.JS ODM" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongoose-orm/km3rBB9UidQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongoose-orm+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
var person = new PersonData{
name: req.body.personName,
_id: ObjectId(1)
}
var location = {
_id: ObjectId(123),
name: req.body.name,
controlledBy: {
kind: 'IndividualData',
controller: person._id
}
}
var data = new LocationData(location);
data.save(function (err, location) {
if (err) return console.error(err);
person.save(function (err) {
if (err) return console.error(err);
});
res.redirect('/get-dataLocation');
});Or do I need to do something specific for the refPath?
--