I have two schemas:
let adSchema = mongoose.Schema (
{
author: {type: ObjectId, ref: 'User'},
title: {type: String, required: true },
town: {type: ObjectId, ref: 'Town', required: true},
}
);
And town schema:
let townSchema = mongoose.Schema (
{
name: {type: String, required:true, unique:true},
ads: [{type: ObjectId, ref: 'Ad'}]
}
);
I need to make query that finds all Ads by town.name
How can I do that?
via petko kostadinov
No comments:
Post a Comment