I am trying reference another object in a model in node,
User = new Schema({
username: {
type: String,
index: {unique: true}
I'd like to add a reply to this question because it's the first result in Google.
No you can't use Nested Schema as the other replies say. But you can still use the same object in different schema.
// Regular JS Object (Not a schema)
var Address = {
address1: String,
address2: String,
city: String,
postalcode: String
};
var Customer = new Schema({
firstname: String,
lastname: String,
address: Address
});
var Store = new Schema({
name: String,
address: Address
});
That way you can modify the Address Object to make the changes available on all your schemas sharing the object.