How to get random record from MongoDB
Radom data is useful to test many scenarios and check our code stability in many ways. We can get random documents from given collection. Solution 1: Using $sample Randomly selects…
Radom data is useful to test many scenarios and check our code stability in many ways. We can get random documents from given collection. Solution 1: Using $sample Randomly selects…
We can use various approaches to get the last n record from database. Let find out which approach suits you. You can use combination of the sort() , limit() ,skip() to get the…
We have various ways to achieve the result. However, we will discuss here two methods. 1. Distinct db.collection.distinct(field, query, options) Finds the distinct values for a specified field across a…
Mongoose schemas support a timestamps option. If you set timestamps: true, Mongoose will add two properties of type Date to your schema: createdAt: a date representing when this document was createdupdatedAt: a date representing when…
First check table space quota for all user or for specific user using sql query. DBA_TS_QUOTAS describes tablespace quotas for all users.USER_TS_QUOTAS describes tablespace quotas for the current user. select * from…
Here are five ways to reduce fetch time of our sql queries. 1 - If you have access to check the execution plan of you query then check which part…
The error is because of the new version of the mongoose i.e version 6.0.6. useNewUrlParser, useUnifiedTopology, useFindAndModify, and useCreateIndex are no longer supported options. Mongoose 6 always behaves as if useNewUrlParser, useUnifiedTopology, and useCreateIndex are true, and useFindAndModify is false. Please remove…
While working on any project where we may have a requirement to check the size of an array or to get an element whose size is greater or less than…