Questions tagged [mongodb-nodejs-driver]

Use this tag for official MongoDB Node.js Driver related Questions.

56 questions
0
votes
1 answer

Isn't it possible to concat new value to a field in MongoDB document while updating it?

I have few documents in a MongoDB Collection and each has a unique field called "requestid". Now I need to update a field "requeststatus" by concatenating a new value to an existing one in NodeJS application. I started using MongoDB for very recent…
shary.sharath
  • 649
  • 2
  • 14
  • 29
0
votes
0 answers

Mongodb Native Driver "find" errors if there are more than 100 documents

I have a collection of 200 documents, when I'm using the "find" method I've got an error MongoServerError: Cannot run getMore on cursor 5866951209337451201, which was created in session bcd516cd-227f-4df6-bc52-5aca331c08e9 -…
Yevhen Kazmirchuk
  • 119
  • 1
  • 1
  • 6
0
votes
1 answer

How to get the schema validator from a mongodb collection using node.js driver?

Is there a ways to get the current schema validator from an existing collection in mongodb 5? I want to write schema migration script for an existing schema by retrieving the current schema validator, adding the changes and updating it…
0
votes
0 answers

domainsEnabled client option removed in node mongodb driver 4.0

Node mongodb native driver version 3.7 provides a domainsEnabled connection option (as described in 3.7 documentation) Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit However, I don't find a similar…
fgalan
  • 11,732
  • 9
  • 46
  • 89
0
votes
1 answer

Mongodb Distinct Query with Count

I have a schema like below in mongodb let reactions = [ { messageId: 1, reactions: [ { "userid": "7212898122", "reactionId": 2, "date": "2022-05-12T18:55:49.943Z" }, …
Deepak
  • 145
  • 2
  • 9
0
votes
1 answer

How do I get a Generic and static reference to a MongoDB collection?

I want to write a static getOne() class method (i.e. it does not require a class instance or the new operator to use it) which is also generic, and which returns MongoDB objects as an Item which is either a Book or a Film. This is my initial…
cprcrack
  • 17,118
  • 7
  • 88
  • 91
0
votes
1 answer

Running custom commands in mongodb node driver

I am in need of creating a code to hide/unhide mongo index in node. There are no such methods on node-mongodb-native although they exist on mongo shell. Second attempt was to run a custom command, but await db.command({ hideIndex: 'some_name' })…
0
votes
1 answer

BSON field ‘listCollections.collation’ is an unknown field

I just started having this weird issue with my db.createCollection calls using the collation option. Though this section of my codebase had been in operation and untouched for years, it is now failing. I just noticed that the db.createCollection…
Stephen Isienyi
  • 1,292
  • 3
  • 17
  • 29
0
votes
2 answers

MongoDB and NodeJS TypeError: mongoClient.close is not a function

When i try to close the connection between NodeJS and MongoDB cluster i get mongoClient.close is not a function. Please help Node JS MongoDB code const mongoClient = require("mongodb").MongoClient; exports.getInfo = async (czytnik_id) => { …
0
votes
0 answers

mongodb error- db.runCommand() is not a function

I want to modify the validation of my collection using collmod command. but when I call the runCommand() function it gives me error runCommand is not a function. I am trying to connect using nodejs driver const uri =…
kanz
  • 11
  • 1
0
votes
1 answer

MongoDB aggregate to extract values from a nested array and return a total

I have this collection structure: [ "_id": "61a013b59f9dd0ebfd23ftgb", "modules": [ { "_id": "61a013b59f9dd0ebfd964dgh", "videos": [ { "_id": "213412", "progress": 100 }, { …
Matt Price
  • 1,371
  • 2
  • 9
  • 19
0
votes
1 answer

How to know mongodb transaction all CRUD success?

execTransaction(session => { return async () => { await db.collection('table1').updateOne({ username: username }, { $push: { apps: client_id } }, { session }); await…
oscxc
  • 1
  • 2
0
votes
2 answers

Could not get mongodb connectivity with nodejs

I have tried this in nodejs but i am getting undefined as output in my console // Connect using a MongoClient instance const MongoClient = require("mongodb").MongoClient; const test = require("assert"); // Connection url const url =…
0
votes
2 answers

How would I know if "err" argument is needed in the callback?

I am a beginner in mongodb and javascript. I have here a code for simple find method in Mongodb Nodejs. This code does not work. The solution is to change the last line to this: cursor.limit(10).toArray((err, docs) => console.log(docs));. What I do…
0
votes
1 answer

how to merge multiple collections in mongodb node js using mongodb driver

I have 3 collections. i want to combine those and filter data from merged data. Business Collection { _id:1, "user_id": 1, "name": "Doll Shopqq", "registered_phone_number": 701006522222109, "business_profile_image_url":…
Joyner
  • 312
  • 1
  • 2
  • 11