0

Say I have updates in database with this schema

{
_id:Number
isRead:[]
}

Say I Have these data

{
    _id: 1, isRead:[1,2],
    _id:2, isRead:[3,4],
    _id:3, isRead:[1]
}

when i use this query

updates.find('isRead':1) in mongo db it returns the needed result which is the first and the last But in mongoose i use the same query but it doesn't return any data, How can I modify my query in mongoose ?

user2285831
  • 419
  • 1
  • 5
  • 18

2 Answers2

0
updates.find(isRead:{$in:[1]})

for $in refer: https://docs.mongodb.com/manual/reference/operator/query/in/

Simran
  • 2,364
  • 1
  • 12
  • 19
0

The solution is to put the type in the schema

isRead[Number]
user2285831
  • 419
  • 1
  • 5
  • 18