express-api-cli icon indicating copy to clipboard operation
express-api-cli copied to clipboard

Mongoose

Open farmanalibhatti opened this issue 4 years ago • 0 comments

//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.

farmanalibhatti avatar Apr 20 '21 10:04 farmanalibhatti