Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Vadim Demedes
    @vadimdemedes
    yeah, there's no .set()
    so changed will be {}
    Matías Olivera
    @olistic
    yeah, but it is instantiating a new Mode
    Model
    Vadim Demedes
    @vadimdemedes
    yes
    and .changed object will be empty, because no properties were changed
    Matías Olivera
    @olistic
    yeah, but that’s the point. Maybe I didn’t explain me well
    Vadim Demedes
    @vadimdemedes
    yeah, I don't really understand the issue
    Matías Olivera
    @olistic
    I want the constructor of the model, to flag all attributes as changed if the model is new
    Vadim Demedes
    @vadimdemedes
    if Post.find, model can't be new, because it is stored already
    Matías Olivera
    @olistic
    so if I check in the changed attribute I can get the modified attributes, whether they have been modified or they are new
    Vadim Demedes
    @vadimdemedes
    you can check if a property is new, if its previous value is undefined
    Matías Olivera
    @olistic
    I will have to go in 5 minutes Vadim, maybe it would be better if I write you an email detailing the issue with more calm
    Vadim Demedes
    @vadimdemedes
    yeah ok
    Matías Olivera
    @olistic
    I think it worth mentioning that I would be pleased to help
    in this or anything that comes up in the future
    Rodrigo Espinosa
    @RodrigoEspinosa
    Hello everybody! Vadim, cheers for a such a great project, I was looking at the code today and it's super clean, really like it!
    I think what @moliveraf was trying to said is that, in order to know if the new model instance comes from a .find, the constructor needs to check if the _id property is defined.
    Rodrigo Espinosa
    @RodrigoEspinosa
    So, lets see, @moliveraf is proposing that the this.set(attrs) should be called from the constructor when the model instance is absolutely new and hasn't been saved yet, is that right @moliveraf ?
    This new behaviour is for populating the changed object before saving the instance.
    In that way, when I create a new model instance, every attribute will be flagged as changed until I save.
    Matías Olivera
    @olistic
    That’s exactly what I want @RodrigoEspinosa
    Callum Lyall
    @BeachedCactus
    Hi there! When I assign a ID before saving using ObjectId from mongorito.ObjectId it doesn't actually save but still passes. Any ideas? Thanks
    Callum Lyall
    @BeachedCactus
    Here is the object I save
    {
      _id: 583d7536b293ffc34acca87b,
      report: 583d7533b293ffc34acca87a,
      name: 'Test 1',
      type: 'hard',
      status: 'ok',
      tolerance: '0.000',
      mergeComposites: undefined,
      clashResults: [...]
    }
    const ObjectId = require('mongorito').ObjectID;
    ...
    let clashtest = {
      _id: ObjectId(),
      report: this.report._id,
       ...
    }
        let ct = new ClashTest();
        ct.set(clashtest);
        yield ct.save();
    Vadim Demedes
    @vadimdemedes
    @BeachedCactus Hey! Sorry for such a late reply. If you set ObjectId before first save, it assumes the document is already in the database, so it calls update() instead of insert(). I think that may be the problem.
    Mathieu Ghennassia
    @mathieug
    Hello. I have troubles trying to chain mongorito.connect() in my promises chain.
    I have this:
    const startupPromise = bluebird.resolve();
    startupPromise
      .then(() => {
        console.info('Connecting to MongoDB...');
        return mongorito.connect(process.env.MONGO_URI, {
          promiseLibrary: bluebird
        });
      })
      .then((db) => {
        console.info(`Connected to MongoDB database ${db.databaseName}`);
      });
    then:
    return startupPromise.then(() => {
      return server.listen(process.env.PORT, () => {
        console.info(`Listening on port ${server.address().port} (${app.get('env')})`);
      });
    });
    And I have "Listening on port..." before "Connected to MongoDB database...".
    Mathieu Ghennassia
    @mathieug
    @vadimdemedes I think it comes from the fix you made for this issue vadimdemedes/mongorito#93
    Mathieu Ghennassia
    @mathieug

    Connecting to MongoDB...
    Listening on port 3000 (development)
    Connected to MongoDB database xxx

    but I would like to get

    Connecting to MongoDB...
    Connected to MongoDB database xxx
    Listening on port 3000 (development)

    Mathieu Ghennassia
    @mathieug
    @vadimdemedes it is planned to support capped collections and tailable cursors?
    Vladislav Yatsun
    @vyatsun
    Is there a way to $unset a field using Mongorito?
    Vadim Demedes
    @vadimdemedes
    @mathieug what is required to support those?
    @vyatsun sure, post.unset('field'); await post.save();