September 3, 2019
noSQL Search Query
Besides using _ID to do searching, you can also use other fields or multiple fields to do searching. For example:
Examples | JavaScript Codes |
By username | db.collection(“comments”).find( {username: “Peter”} , {limit: 1000}).asArray() It will search all comments with username = “Peter” |
By Date | db.collection(“comments”).find( { date: “01/01/2018”} , {limit: 1000}).asArray() It will search all comments with date = “01/01/2018”. |
By both Username and Date | db.collection(“comments”).find( {username: “Peter”, date: “01/01/2018”} , {limit: 1000}).asArray() It will search all comments with username = “Peter” and date = “01/01/2018”. |
You see, it is very simple to write such noSQL query.