Hi All,
We are using Ottoman v2 module for our application development, I have few doubts,
-
How to unset the specific key at the document in Ottoman, previously i was used mongodb for unset function i know , ex: current document is
{ _id:“b0de5a04-7310-4865-842a-f47d231d1e3c”,
name:“Store Users”,
network:[4,5],
created_at:“2021-03-10T10:55:05.647Z”
}
i want to remove network key. -
I need to select all the fields to except _type field, how to make this option
await DepartmentModel.find({$or:[{change_status:1},{seq_status:1}]},{$all:’’,sort:{created_at:‘DESC’}});
[{"_type":“Departments”,“name”:“Learning Algorithm”,“seq_status”:1,“sequence”:2,“change_status”:0,“created_at”:“2021-03-10T10:55:05.647Z”}] -
How to select specific populated fields at the Model
await DepartmentModel.find({$or:[{change_status:1},{seq_status:1}]},{populate: ‘updated_by’,$all:’’,sort:{created_at:‘DESC’}});
above DepartmentModel query populate return below result,
{"_type":“Departments”,“name”:“Learning portal”,“seq_status”:1,“sequence”:2,“change_status”:0,“created_at”:“2021-03-10T10:55:05.647Z”,“id”:“2facd8b1-abb4-40cf-8e8e-e5cae5543157”,“status”:1,“updated_at”:“2021-03-10T10:57:40.180Z”,“updated_by”:{“uq_id”:“a-jd772892”,“name”:{“first”:“Rajasekar”,“last”:“Murugesan”},“claims":“XXXXXXXXXXXXXX-YYYYYYYYY-ZZZZZZZZZ”,“email”:"rajasekar@yahoo.com”,“id”:“b0de5a04-7310-4865-842a-f47d231d1e3c”,"_type":“Users”}}
but i want to select specific populated field as “uq_id” not all populated field at User Model,
Expected Result:
{"_type":“Departments”,“name”:“Learning portal”,“seq_status”:1,“sequence”:2,“change_status”:0,“created_at”:“2021-03-10T10:55:05.647Z”,“id”:“2facd8b1-abb4-40cf-8e8e-e5cae5543157”,“status”:1,“updated_at”:“2021-03-10T10:57:40.180Z”,“uq_id”:“a-jd772892”}
Thanks :),