Unsupported projection mongodb in nodejs
my code is : result = await mongoDBO.collection(collectionName).find({id: data.id},{projection : {'_id' : 0}}).toArray(); But I get the following error Unsupported projection option: projection: { _id: 0 }
my code is : result = await mongoDBO.collection(collectionName).find({id: data.id},{projection : {'_id' : 0}}).toArray(); But I get the following error Unsupported projection option: projection: { _id: 0 }
I have 3 schemas: const userSchema = new mongoose.Schema({ username:{ type: String, unique: true }, password:{ type: String }, tasks:{ type:[mongoose.Types.ObjectId] } }) const taskSchema = new mongoose.Schema({ title:{ type: String }, finished:{ type: Boolean }, deadline:{ type:Date }, subtasks:{…
I'm trying to connect to my MongoDB localhost but it just won't connect. What happens is when I go to /admin, it just keeps loading and I get no messages, no nothing in the logs. I have no idea why.…
I have a nodejs lambda function that needs to search into an opensearch DB. I want to use the aws-sdk-v3. I found the doc here for OpenSearchClient: https://github.com/aws/aws-sdk-js-v3/tree/246d6534c53dcf9bd2eb6a620cb5b6c04b27451a/clients/client-opensearch But as you see, there is almost nothing explained there. For example,…
I use MongoDB to store user data. The user id goes incrementally, such as 1, 2, 3, 4 etc when new user register. I have the following code to generate the user id. "users" is the name of the collection…
Using Node, Express and Mongoose, I'm trying to insert data into MongoDB through a POST method. The fields I'm trying to insert has a phone field on which I'm trying to assign a validation that will check if it has…
So I'm trying to print out only the year data because I want to perform some functions on it. the q var is coming form a html form so we don't know what will be the value of q the…
Here is my Controller const getCountofCenters = async (req, res) => { const result = Center.countDocuments(); await result.then(() => res.status(200).send(result)) .catch((err) => { res.status(200).send(err) }); } This is the Api call router.get("/count", CenterController.getCountofCenters); This is the output which I get…
const mongoose = require("mongoose"); mongoose.connect("mongodb://localhost:27017/fruitsDB", {useNewUrlParser: true}); const fruitSchema = new mongoose.Schema ({ name: String, rating: Number, review: String }); const Fruit = mongoose.model("Fruit", fruitSchema); Fruit.find((err, fruits) => { if (err) { console.log(err); } else { fruits.forEach((fruit) => console.log(fruit.name)); };…
Good evenings, sirs. I wonder how can i delete records in Sequelize after certain time passes? For example, I want to delete unauthorized records after 10 days.I am new to Sequelize so if you can give me an idea, i…