express-api-cli
express-api-cli copied to clipboard
Mongoose
//get user Profile
public getUserProfile = async (user_id: string): Promise<any> => {
console.log("Validity =====>", Mongoose.Types.ObjectId.isValid(user_id));
const data = await Profile.findOne({ user: Mongoose.Types.ObjectId.createFromHexString(user_id) });
return data;
};
In this service, I am unable to map proper type. Can you please help me with that? I am getting error below:
Type 'ObjectId' is not assignable to type 'Condition<{ type: ObjectId; }>'.
Type 'ObjectId' has no properties in common with type 'QuerySelector<{ type: ObjectId; }>'.
This is an object id of user that I am trying to access in profile model.