Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 00:17
    mbroadst synchronize #2192
  • 00:17
    mbroadst synchronize #2192
  • 00:17
    mbroadst synchronize #2192
  • 00:17

    mbroadst on replset-leaking-unknown-servers

    fix(replset): don't leak server… feat(sdam_viz): support legacy … (compare)

  • 00:17

    mbroadst on replset-leaking-unknown-servers

    fix(replset): don't leak server… feat(sdam_viz): support legacy … (compare)

  • 00:17

    mbroadst on replset-leaking-unknown-servers

    fix(replset): don't leak server… feat(sdam_viz): support legacy … (compare)

  • Oct 23 22:14

    mbroadst on fix-topology-id-legacy-replset

    (compare)

  • Oct 23 22:14

    mbroadst on fix-topology-id-legacy-replset

    (compare)

  • Oct 23 22:14

    mbroadst on fix-topology-id-legacy-replset

    (compare)

  • Oct 23 22:14

    mbroadst on master

    fix(replset): use correct `topo… (compare)

  • Oct 23 22:14

    mbroadst on master

    fix(replset): use correct `topo… (compare)

  • Oct 23 22:14

    mbroadst on master

    fix(replset): use correct `topo… (compare)

  • Oct 23 22:14
    mbroadst closed #2191
  • Oct 23 22:14
    mbroadst closed #2191
  • Oct 23 22:14
    mbroadst closed #2191
  • Oct 23 19:27
    daprahamian review_requested #2186
  • Oct 23 19:27
    daprahamian review_requested #2186
  • Oct 23 19:27
    daprahamian review_requested #2186
  • Oct 23 19:27
    daprahamian commented #2186
  • Oct 23 19:27
    daprahamian commented #2186
Nuri Ha
@Nurih_twitter
@Sherlocked556 Did you look at change streams? https://mongoosejs.com/docs/models.html#change-streams
Luiz Henrique Pegoraro
@lpegoraro
Hey guys, can I use aggregate() to update a collecion based on another collection?
七八个星天怪
@oscxc
Is anybody there?
...
stherrienaspnet
@stherrienaspnet
Hello, can anyone help me with replicatset configuration
Is it possible to configure and run replicatset without using rs.initiate...command?
Rob
@robinfehr

Hi there - I'm trying to verify the options we're applying when establishing a connection.
we're setting the following:

repository.options.w = 'majority';
repository.options.j = true;
repository.options.readConcern = { level: 'linearizable' };
repository.options.retryWrites = true;
repository.options.wtimeout = 5000;

once the connection is established, I'd like to verify if the options have been applied.
Can I do that from within the driver? Or is there an option too from within mongodb itself?

https://stackoverflow.com/questions/57114721/how-to-verify-mongodb-options-set-on-connection-level

Nuri Ha
@Nurih_twitter
Afaik
AFAIK No: Can't create a replica set without rs.initiate (or the underlying runCommand equivalent)
Titusvimalraj
@Titusvimalraj
Hi guys I need help with a requirement. I'm trying to keep history of documents after a certain change and if found that findAndModify() with new:true return a modified document instead of the original. it was working fine I had got new document with new Id but the next day I tried, it returns only the original document id with modifications instead of new document with new id and modifications
verilog15
@verilog15
Hi guys, can someone help with a small query?
Mahendra Lakmal
@mahendralakmal
guys can anyone help me on following,
Im getting following error when mongo webui up.
mongo-webui_1 | {"error":{"name":"MongoParseError"},"level":"error","message":"uncaughtException: Invalid connection string\nError: Invalid connection string\n at parseConnectionString (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/uri_parser.js:412:21)\n at connect (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/operations/mongo_client_ops.js:188:3)\n at connectOp (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/operations/mongo_client_ops.js:292:3)\n at executeOperation (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/utils.js:420:24)\n at MongoClient.connect (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/mongo_client.js:168:10)\n at Function.MongoClient.connect (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/mongo_client.js:372:22)\n at new MongoConnection (packages/mongo/mongo_driver.js:177:11)\n at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16)\n at Object.<anonymous> (packages/mongo/remote_collection_driver.js:38:10)\n at Object.defaultRemoteCollectionDriver (packages/underscore.js:784:19)\n at new Collection (packages/mongo/collection.js:97:40)\n at collections.js (lib/imports/collections.js:3:24)\n at fileEvaluate (packages/modules-runtime.js:336:7)\n at Module.require (packages/modules-runtime.js:238:14)\n at Module.moduleLink [as link] (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/modules/node_modules/reify/lib/runtime/index.js:38:38)\n at index.js (server/imports/modules/database/index.js:1:24)","stack":"Error: Invalid connection string\n at parseConnectionString (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/uri_parser.js:412:21)\n at connect (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/operations/mongo_client_ops.js:188:3)\n at connectOp (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/operations/mongo_client_ops.js:292:3)\n at executeOperation (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/utils.js:420:24)\n at MongoClient.connect (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/mongo_client.js:168:10)\n at Function.MongoClient.connect (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/mongo_client.js:372:22)\n at new MongoConnection (packages/mongo/mongo_driver.js:177:11)\n at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16)\n at Object.<anonymous> (packages/mongo/remote_collection_driver.js:38:10)\n at Object.defaultRemoteCollectionDriver (packages/underscore.js:784:19)\n at new Collection (packages/mongo/collection.js:97:40)\n at collections.js (lib/imports/collections.js:3:24)\n at fileEvaluate (packages/modules-runtime.js:336:7)\n at Module.require (packages/modules-runtime.js:238:14)\n at Module.moduleLink [as link] (/opt/meteor/dist/bundle/programs/server/npm/node_modules/meteor/modules/node_modules/reify/lib/runtime/index.js:38:38)\n at index.js (server/imports/modules/database/index.js:1:24)","exception":true,"date":"Tue Jul 30 2019 03:29:30 GMT+0000 (UTC)","process":{"pid":1,"uid":1000,"gid":999,"cwd":"/opt/meteor/dist/bundle/programs/server","execPath":"/opt/nodejs/bin/node","version":"v8.4.0","argv":["/opt/nodejs/bin/node","/opt/meteor/dist/bundle/main.js","program.json"],"memoryUsage":{"rss":116289536,"heapTotal":85393408,"heapUsed":64070104,"external":20273372}},"os":{"loadavg":[1.7
dimtabu
@taburetkin
guys, how to correctly handle connect to server
1) with wrong credentials
2) to not exist database
it seems that in both cases client = new MongoClient(url, { useNewUrlParser: true }); client.connect() resolved without errors
Mike
@skazx_twitter

@taburetkin
``` MongoClient.connect("mongodb://localhost:27017/integration_tests", {native_parser:true}, function(err, db) {
assert.equal(null, err);

db.collection('mongoclient_test').update({a:1}, {b:1}, {upsert:true}, function(err, result) {
  assert.equal(null, err);
  assert.equal(1, result);

  db.close();
});

});```

dimtabu
@taburetkin
@Mike, thanks for the response, but can you explain it a litle bit? I feel my self like a dumb ass because i can not get how your message answers my questions
Karan Nagpal
@KaranNP

var User = require('../models/user');
var userModel = require('../database').models.user;

I was running a code from github and came across these two lines, They look similar but definitely work differently. Whats the difference between the two lines ?

Zijing Zhang
@zzj0402_gitlab
So my local test works fine but GitLab CI is complaining about connection: https://gitlab.com/zzj0402/moaserver/-/jobs/272837637
John Skoteiniotis
@j0hnskot
Not sure if this is the proper place to ask but here it is: i have a field named "something" which is set to string tupe
christian
@kresdjan
Hi, can someone point me to a place in the docs or guides that shows how to best setup MongoClient in a Node/Express app?
How do you setup mongoClient connection so you don't have to connect in every route? Is there a smart why to connect once and let all routes etc. use or share that connection?
syedsimanta03
@syedsimanta03
OS related question what u prefer for web and app dev- apple Mac os or Linux?
Neil Duffy
@skiv71
i'm ashamed to say, winblows with WSL
Vimal Mistry
@vimalmistry
Hi, Everyone. I have mongodb collection like { convid,users:[1,2]}
How can I search on collection which contain users id 1 and 2 both?
Acristinescu
@best4him
Hi! Have you any idea why I don't get any error in the first example? If I use a callback, I get MongoTimeoutError.
        await server.stop();
        try {
            const r = await db.things.insertOne({ a: 1 }); //no erro, r is null
            assert(!r);
        } catch (err) {
            console.log(err);
        }
        await server.restart();
        const r = await db.things.insertOne({ a: 1 });
        assert(r.insertedCount === 1);
    db.things.insertOne({ a: 1 }, (err, result) => {
                if (err) { //"MongoTimeoutError" "Server selection timed out after 10000 ms"
                    return reject(err);
                }
                resolve(result);
            })
Nadia
@nadiaschutz
hi guys
Neil Duffy
@skiv71
hey
Nadia
@nadiaschutz

> use my-blog
switched to db my-blog

> db.articles.insert([{
... name: 'learn-react',
... upvotes: 0,
... comments: []
... }, {
... name: 'learn-node',
... upvotes: 0,
... comments: [],
... }, {
... name: 'my-thoughts-on-resumes',
... upvotes: 0,
... comments: []
... }])
BulkWriteResult({
        "writeErrors" : [ ],
        "writeConcernErrors" : [ ],
        "nInserted" : 3,
        "nUpserted" : 0,
        "nMatched" : 0,
        "nModified" : 0,
        "nRemoved" : 0,
        "upserted" : [ ]
})
> db.articles.find({})
{ "_id" : ObjectId("5d66f2fce32a85d63cd95c51"), "name" : "learn-react", "upvotes" : 0, "comments" : [ ] }
{ "_id" : ObjectId("5d66f2fce32a85d63cd95c52"), "name" : "learn-node", "upvotes" : 0, "comments" : [ ] }
{ "_id" : ObjectId("5d66f2fce32a85d63cd95c53"), "name" : "my-thoughts-on-resumes", "upvotes" : 0, "comments" : [ ] }
> db.articles.find({}).pretty()
{
        "_id" : ObjectId("5d66f2fce32a85d63cd95c51"),
        "name" : "learn-react",
        "upvotes" : 0,
        "comments" : [ ]
}
{
        "_id" : ObjectId("5d66f2fce32a85d63cd95c52"),
        "name" : "learn-node",
        "upvotes" : 0,
        "comments" : [ ]
}
{
        "_id" : ObjectId("5d66f2fce32a85d63cd95c53"),
        "name" : "my-thoughts-on-resumes",
        "upvotes" : 0,
        "comments" : [ ]
}
> ^C

bye
Neil Duffy
@skiv71
Oh hi Nadia, I remember commenting on your github :)
Nadia
@nadiaschutz
> show collections
> use my-blog
switched to db my-blog
> show collections
> show dbs
CRMdb   0.000GB
admin   0.000GB
config  0.000GB
local   0.000GB
> show databases
CRMdb   0.000GB
admin   0.000GB
config  0.000GB
local   0.000GB
> show dbs^C
i had bunch of test data before current my-blog db data. any ideas why it's not showing anything?
@skiv71 haha such a good memory you have
Neil Duffy
@skiv71
sometimes, lol
Nadia
@nadiaschutz
never mind it's working now
had to restart mongod
🤔
dimtabu
@taburetkin
what do you mean by "share connection"
syedsimanta03
@syedsimanta03
I need your help. I want to know if there is any free hosting for deploying NODE MONGO EXPRESS PUG app?
Luiz Henrique Pegoraro
@lpegoraro
@syedsimanta03 maybe heroku, I host a meteor app there
syedsimanta03
@syedsimanta03
@lpegoraro so u hv submitted ur credit card info as they are asking for it for mongoLab addon?
Luiz Henrique Pegoraro
@lpegoraro
@syedsimanta03 I already had one registered there, so maybe it is needed... sorry, forgot about that, never got charged for that app though
syedsimanta03
@syedsimanta03
@lpegoraro thatz cool
syedsimanta03
@syedsimanta03
const courses = Course
  .find( { author: "Simanta", isPublished: true } )
  .limit(10)
  .sort({ name: 1 })
  .select({ name: 1, tags: 1 })

  console.log(courses);
Can you plz explain why should we use 1 in .select({ name: 1, tags: 1 }) -> select query
syedsimanta03
@syedsimanta03
app.post('/name', (req, res) => {
  let name = req.body.first + ' ' + req.body.last;
  res.json({name: 'firstname lastname'});
});
the - req.body.first -> so .first or .last is coming from the html or what is it actually after req.body.
AliFetvaci
@aliFetvaci61

processedAt field (TIMESTAMP) In the Collection has Different format WHY ? Can you Explain ?

For Example
May 21, 2019 3:43:12 PM
Tue May 21 15:45:42 EET 2019
Thu May 30 09:25:54 EET 2019
Jun 12, 2019 2:42:09 PM
Jun 12, 2019 4:16:19 PM
Thu Jun 20 15:43:18 EET 2019
Fri Jun 21 08:57:21 EET 2019
Jun 21, 2019 4:24:04 PM
Mon Jun 24 13:24:21 EET 2019
Mon Jun 24 13:24:16 EET 2019

taphuocanh94
@taphuocanh94

Hi all, I have a problem with mongoose, help me please

const M_Posts = new Schema({
    title: { type: String, required: true },
    content: { type: String, required: true },
    by_user: { type: Schema.Types.ObjectId, ref: 'Users' },
    comments: [{
        content: String,
        by_user: { type: Schema.Types.ObjectId, ref: 'Users' },
        reply_for: { type: Schema.Types.ObjectId, ref:'posts.comments' },
    }],
});
const Posts = mongoose.model('posts', M_Posts);
Posts.create({ title: 'Post 1', content: 'Post 1 content' })
    .then(post => {
        var comment_1 = post.comments.create({
            content: 'Content comment 1',
        });

        var reply_comment_1 = post.comments.create({
            content: 'Reply for comment 1',
            reply_for: comment_1._id,
        });

        post.comments.push(comment_1);
        post.comments.push(reply_comment_1);
        return post.save();
    }).then(post => {
        console.log(post);
        return Posts.findById(post._id).populate('comments.reply_for');
    }).then(console.log).catch(console.log);

This is my posts schema. When I run this code, I'm received an error:

{ MissingSchemaError: Schema hasn't been registered for model "posts.comments".
Use mongoose.model(name, schema)
    at new MissingSchemaError (\node_modules\mongoose\lib\error\missingSchema.js:22:11)
    at NativeConnection.Connection.model (\node_modules\mongoose\lib\connection.js:973:11)
    at getModelsMapForPopulate (\node_modules\mongoose\lib\helpers\populate\getModelsMapForPopulate.js:200:59)
    at populate (\node_modules\mongoose\lib\model.js:4083:21)
    at _populate (\node_modules\mongoose\lib\model.js:4053:5)
    at utils.promiseOrCallback.$wrapCallback.cb (\node_modules\mongoose\lib\model.js:4028:5)
    at Promise (\node_modules\mongoose\lib\utils.js:271:5)
    at new Promise (<anonymous>)
    at Object.promiseOrCallback (\node_modules\mongoose\lib\utils.js:270:10)
    at Function.Model.populate (\node_modules\mongoose\lib\model.js:4027:16)
    at Posts.create.then.then.post (\app\models\Comments.js:33:22)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  message:
   'Schema hasn\'t been registered for model "posts.comments".\nUse mongoose.model(name, schema)',
  name: 'MissingSchemaError' }
Evgen Koshmaryk
@koshmaryk
Hello! Can anyone help? Suppose we have replica_set of 3 members. If one member gone down. After come back and finally getting the ‘SECONDARY’ state by this member is it guaranty of full sync with primary?
Stavros Kefaleas
@skiabox
hello
Robert D. Blanchet Jr.
@blanchet4forte
if I have a document with an array of sub documents. what are my options for upserting an element in that array?
Dj-jom2x
@Dj-jom2x
hello i have question do you really need to pay if you wanted to install mongodb enterprise on your local server? i install it it looks like same as community .. does it have trial that ends like that? or limits.. and need license?
Nuri Ha
@Nurih_twitter
You can use $addToSet to avoid inserting same element twice.