USE ONLY IF YOUR QUESTION IS VERSION-SPECIFIC. For questions about MongoDB programming that are specific to version 4+ of the language. Use the more generic [mongodb] tag on all MongoDB questions.
Questions tagged [mongodb4.0]
39 questions
1
vote
0 answers
Dot notation in MongoDB InsertOne
While performing InsertOne in MongoDB (4.0.5) from PHP I get the following exception:
[0] Detected unsupported PHP type for field path "context.trace.1.args.2": 7
According to the MongoDB documentation one is allowed to use dot notation in update…

Bart Gloudemans
- 1,201
- 12
- 27
1
vote
0 answers
MongoDB add replica-set to external server by ip
I have created 3 Digitalocean droplet. By default, I choose Ubuntu 18.06 and MongoDB 4.
Here I have 3 droplets by default MongoDB config and all are up. I have access to "mongo" shell for all of them.
Now I want to run a replica-set setting by this…

Abdol Seed
- 1,227
- 1
- 14
- 23
1
vote
1 answer
Can MongoDB changeStreams listen to system level collections?
With the limited documentation available on MongoDB changestreams which they introduced version 3.6 onwards, I am not able to conclude if MongoDB changestreams let us listen to system collection changes.
Currently, I am interested in system.profile…

Hemant Patel
- 13
- 4
1
vote
0 answers
Multi-document ACID transactions in Mongoid 7.0.1
Support for multi-document transactions are released recently with Mongo 4.0. With the release of Mongoid 7.0.1 (Mongo 2.6.1 driver), multi-document transactions seems to be supported on Rails now.
However the documentation website for Mongoid is…

CyberMew
- 1,159
- 1
- 16
- 33
1
vote
1 answer
TypeError: Cannot read property 'n' of undefined\n at result.toArray
I'm upgrading from mongodb 3.6 to mongodb 4.0 and have problem with aggregates (it seems).
I've got this error:
TypeError: Cannot read property 'n' of undefined\n at
result.toArray
…

Orelsanpls
- 22,456
- 6
- 42
- 69
0
votes
1 answer
Rename database and indexes during mongorestore
I'm migrating data from a mongo 4.0 server to aws documentdb (docdb4.0 family), and I've run into the error createIndex error: namespace name generated from index name is too long which has been reported with some frequency. However, I have not seen…

jonesy
- 3,502
- 17
- 23
0
votes
1 answer
Keep on getting MongoNetworkError connection 6 to xx.x.xx.xx:xxxxx closed
I keep on getting the below error in an AWS Lambda with Node.js 16 + MongoDB v4, this usually happens for a lambda that has high traffic, other lambdas seem fine with the current setup.
MongoNetworkError: connection 6 to xx.x.xx.xx:xxxxx closed at…

Nicolae Maties
- 2,476
- 1
- 16
- 26
0
votes
1 answer
Aggregate pipeline for updates not supported in Mongo 4.0
Here is an example of my data:
{
"_id" : ObjectId("6144f74c066fee820d28b34f"),
"Login" : ISODate("2021-09-16T21:09:00.000Z"),
"DiaryNotes" : [
{
"Message" : "Metus tincidunt ultricies.",
"Timestamp" :…

Ben Druitt
- 51
- 1
- 2
0
votes
0 answers
How can I find documents which matching field and data perfectly(not same data order)
I'm begginer at mongoDB
I want to get documents which matching perfectly in mongoDB. id 1 and id 5 document have same fields(but "favorite.foods.fastfood" array not same order).
I mean, I want to get id 1 and 5 but not id 4.
here are documents
[
…

bob
- 3
- 4
0
votes
1 answer
MongoDB - How to find for both string and string array
I'm a beginner at MongoDB.
I want to find documents in MongoDB by favorite.foods.
Here are documents
{
"_id":1,
"favorite": {
"color":"red",
"foods":{
"fruits":"banana",
"fastfood":["burger", "sandwich"]
}
}
},
{
…

bob
- 3
- 4
0
votes
1 answer
Cannot use timestamp from oplog for filtering
I have a stream of oplog messages produced by MongoDB Kafka connector. I want to tell the connector to start producing messages from a given point in time. I can do it using pipelines [documented…

kabanek
- 303
- 3
- 18
0
votes
1 answer
cannot filter with $match a node by another subnodes value in MongoDB
environment: Mongo 4.2.2. invoking from Compass 1.20.5
I did $unwind 2 elements of an array (of a single document) into 2 single documents:
{
{ id: 1 },
{ termTrg: { lang: "ara"} },
{ sublangTrans: { lang: "apj"} }
}
and
{
{…

feder
- 1,849
- 2
- 25
- 43
0
votes
0 answers
Failed: dbName.collectionName: error restoring from collectionName.bson: reading bson input: unexpected EOF
I have an error when try to restore a 32GB database in MongoDB. I've tried the following commands but none of them works:
mongorestore --db prod --drop --dir backup-cloud-server/20200221020001/prod --batchSize=1
mongorestore --db prod --drop --dir…

Simoyw
- 681
- 1
- 9
- 30
0
votes
1 answer
Mongo Write Client connection
What does the MongoDB_ActiveClientsWriting_ metric in mongostat refer to?
If I am performing multiple writes from an application on the same connection - does it get audited as a single Active Client?
In that case - does a connection indicate a…

IUnknown
- 9,301
- 15
- 50
- 76
0
votes
3 answers
Filter out empty element documents
We have a shop collection as below.
We need to return all UNIQUE 'shop' having NO batch as empty([]).
Since this is a stage in the aggregation - it would not be able to avail of index.
So we need to find the most efficient way to do the above.
{
…

IUnknown
- 9,301
- 15
- 50
- 76