Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Jason Kurian
    and there's plenty of good templates https://github.com/jsdoc3/jsdoc
    Jason Kurian
    @mathieudutour just curious, was Automattic/monk#64 implemented in v3?
    and Automattic/monk#43 can be solved by using findOneAndUpdate right?
    Jason Kurian
    @mathieudutour I also suggest enabling http://greenkeeper.io :)
    Mathieu Dutour
    not, #64 is not implemented yet. #85 neither. Want to have a go?
    regarding #43, yes you can use findOneAndUpdate
    I don't really like save in general because it's not an atomic operation
    Mathieu Dutour
    and what are your though about Automattic/monk#145 and Automattic/monk#143 ?
    (and I don't have to right to enable greenkeeper)
    Jason Kurian
    fair enough
    I'll make some comments :)
    can't promise to get to #64 or #85 anytime soon :(
    Ramanpreet N.
    @mathieudutour, what was the reason for switching away from mongoskin in v3?
    Mathieu Dutour
    @rsnara mongoskin is not maintained anymore and there have been discussion of deprecating it: https://github.com/kissjs/node-mongoskin/issues/107#issuecomment-188329836
    Ramanpreet N.
    @mathieudutour cool, makes sense
    Hi anyone here?
    Mathieu Dutour
    Godzsák Dávid
    This message was deleted
    This message was deleted
    This message was deleted

    What is best way to close the connection?

    I have a utility file which creates and execute query against mongo, problem is how to close connection properly. since API is promised based if the close method called at the of method then it doesn't return any thing since promised hasn't been completed, for example:

    var monk = require('monk');
    const db = monk('localhost/mydb');
    const users = db.get('users');

    This doesn't print anything, because db connection get closed too soon.

    Any suggestion?

    Mathieu Dutour
    var monk = require('monk');
    const db = monk('localhost/mydb');
    const users = db.get('users');
    }).then(() => db.close());
    Tim Berry
    users.find({}).each((user, {close, pause, resume}) => {
      // the users are streaming here
      // call `close()` to stop the stream
    }).then(() => {
      // stream is over
    Is the .each a promise? If so what does it do?
    How can I create a database in a server using monk
    Gregor Plavčak
    You can dynamicly set connection url: 'localhost:27017/test'. Database is automaticly created.
    Batyr Nuryyev
    Anyone here?
    Just wanted to ask about queries and options. So, when I send query { username: "foo", email: "bbb@bbb.com" } , I want Monk to check if one the rows (entries) satisfy one or both of those query parameters (if the same username or same email exists, return promise) . But I did not find any specific for that purpose in the docs. How can I do that (basically, how can I implement OR operator with query params)? Thanks!
    Mathieu Dutour
    hi @oneturkmen, that's not monk specific, you should check the mongodb docs. Something like this should work:
        $or: [
            { username: "foo" },
            { email: "bbb@bbb.com}
    Vinicius Camargo
    Hmm I didn't know monk had a gitter room
    I'm just passing to say that monk is an awesome project :thumbsup:
    Andrej Rapoport


    I have a small question about error handling. In my example I pass an invalid ID and this is not handled by the catch function, instead an exception is raised Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters:

    db.get('my').findOne({_id : "123"})

    Shouldn't any kind of error be handled by the promise?


    Hello. I'm having some troubles with aggregation. At my company we are using monk 0.9.0 and co-monk 1.0.0. The problem is that when I execute aggregation without cursor, mongo gives me error that cursor is required. Then when I add cursor nothing happens with function. I would appreciate if anybody can help me out.
    var t = yield new Promise(function(resolve, reject) {
              { $match: { AdminId: "admin@example.com" }},
              { $lookup: { from: "Class", localField: "CompanyId", foreignField: "CompanyId", as: "Classes" }},
              { $unwind: "$Classes" },
              { $group: { _id: "$CompanyId", total: { $sum: { $size: { $ifNull: ["$Classes.History", []]} } } }}
            ], { cursor: { }},
            function(err, res) {
              if (!err){ 
    Jack Durrant
    Looking at Monk's release history on NPM, it hasn't had a new release for 10 months, previously receiving an update every couple of months or so. Is this project still active?
    Dexter Marks-Barber

    Hey! I'm currently using Monk with NextJS, but I noticed Monk doesn't cache database connections, so I reached my Atlas warning fairly quickly. What's the best method of caching database connections with Monk?

    Example Atlas article