Skip to content

update/delete single row #111

Closed
Closed

Description

@GoNode5

Mysql: what would be the code for updating an row:
I see one example;
people[0].save(function (err) {
// err.msg = "under-age";
});
DML: Driver.prototype.update
DML: Driver.prototype.remove

not sure wich way to go?

Activity

  1. dxg commented on Apr 10, 2013

    @dxg
    Collaborator
    dm.models.person.get(1, function(err, item) {
      item.name = 'Jacque';
      item.save( ...
    });

    For changing many attributes at once I used: _.extend(item, attributes);

    There is no publicly exposed item.update(attrs, cb) method.

    Definitely on the todo list..

  2. dresende commented on Apr 10, 2013

    @dresende
    Owner

    It's an easy function to do. About the "delete single row" issue, you can just do:

    item.remove(function (err) { // callback optional
        if (!err) console.log("removed!");
    });
  3. dresende commented on Apr 10, 2013

    @dresende
    Owner

    Instead of creating another method in every instance (which could conflict with properties names and we want to avoid it), I changed .save() to support the following different options.

    item.save(); // just save, no callback given
    item.save(cb); // save with callback
    item.save({ name: "Jacque" }); // update 'name', save, no callback given
    item.save({ name: "Jacque" }, cb); // update 'name', save with callback
  4. dxg commented on Apr 10, 2013

    @dxg
    Collaborator

    Makes sense. Nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions