It’s difficult to use simple sentences, at least my scope doesn’t feel realistic. I can provide some ideas:
Use db.coll.find({},{"Only display one column of data, or a few columns, the fewer the better. It is not easy to use when the amount of data is large, because sorting operation is required later"})$natual:1 After sorting, assign the value to the cursor, and then use two variables in forEach() to save the current piece of data and the previous piece of data until the matching condition is successful, and then the three pieces of data before and after and the current piece of data can be returned. There may be other more awesome internal methods, welcome to share
Another way is to add a column of ordered numbers or characters based on the data that comes out of $natural:1 regularly, and then save it to another new table, and then query the matching data of the new table based on the ID of the new table. Finally, the KEY: value column that was found and added in order was queried again and the data before and after came out.
It’s difficult to use simple sentences, at least my scope doesn’t feel realistic.
I can provide some ideas:
Use db.coll.find({},{"Only display one column of data, or a few columns, the fewer the better. It is not easy to use when the amount of data is large, because sorting operation is required later"})$natual:1 After sorting, assign the value to the cursor, and then use two variables in forEach() to save the current piece of data and the previous piece of data until the matching condition is successful, and then the three pieces of data before and after and the current piece of data can be returned.
There may be other more awesome internal methods, welcome to share
Another way is to add a column of ordered numbers or characters based on the data that comes out of $natural:1 regularly, and then save it to another new table, and then query the matching data of the new table based on the ID of the new table. Finally, the KEY: value column that was found and added in order was queried again and the data before and after came out.