I have some problem with foreign relations.
This is the service
public getCstateByCountry = async (country_id: string): Promise<ICState> => {
const data = await Cstate.find({ country: Mongoose.Types.ObjectId(country_id) });
return data;
};
And this is the model
const cstateSchema = new Schema(
{
name: {
type: String,
unique: true,
},
country: {
type: Mongoose.Schema.Types.ObjectId,
ref: 'Country'
}
},
{
timestamps: true
}
);
I am getting this error
Type 'ObjectId' is not assignable to type 'Condition<ObjectId>'.
Type 'ObjectId' has no properties in common with type 'QuerySelector<ObjectId>'.