Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Join these two documents for API calls #439

Open
Ramakrishnatp opened this issue Mar 7, 2018 · 1 comment
Open

How to Join these two documents for API calls #439

Ramakrishnatp opened this issue Mar 7, 2018 · 1 comment

Comments

@Ramakrishnatp
Copy link

City Document :
{
"_id" : ObjectId("555ec317e6e8ce4e0d3c2541"),
"state" : ObjectId("54f91ea29f2e20e67d61ba6c"),
"deleted" : false,
"created" : ISODate("2015-05-22T05:48:07.831Z"),
"description" : "",
"name" : "Hydrabad",
"__v" : 0
}

State Document:
{
"_id" : ObjectId("54e461ef7214e6583c0c5ed5"),
"__v" : 0,
"created" : ISODate("2015-02-18T09:57:03.585Z"),
"deleted" : false,
"description" : "",
"name" : "Andhra pradesh",
"updated" : ISODate("2016-10-09T18:20:29.601Z")
}

Schemas :
StateSchema = new Schema({
_id: { type: String },
statename: { type: String, required: true, max: 50 }

})

CitySchema = new Schema({
id: mongoose.Schema.Types.ObjectId,
name: { type: String, required: true, max: 50 },

statename: { type:String, ref: 'State' ,field: 'state'},
deleted: Boolean,

});

@gianpaj
Copy link

gianpaj commented Mar 23, 2018

@Ramakrishnatp see http://mongoosejs.com/docs/populate.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants