Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the documentation with the example how to use _run function #33

Open
kalkusa opened this issue Jul 26, 2018 · 3 comments
Open

Add the documentation with the example how to use _run function #33

kalkusa opened this issue Jul 26, 2018 · 3 comments

Comments

@kalkusa
Copy link

kalkusa commented Jul 26, 2018

_run function (see below) is not documented (https://db-migrate.readthedocs.io/en/latest/API/programable/#run)

/**

  • Gets a connection and runs a mongo command and returns the results
  • @param command - The command to run against mongo
  • @param collection - The collection to run the command on
  • @param options - An object of options to be used based on the command
  • @param callback - A callback to return the results
    */
    _run: function(command, collection, options, callback) {

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@rymut
Copy link

rymut commented Nov 25, 2018

The function in question _run is not a part of db-migrate, it is internal function called by db-migrate-mongodb.

As for the usage as far I understand it should not be called directly, with the exception of accessing getDbInstance or other commands like remove, to get full command list see the definition of _run method in index.js.

@wzrdtales
Copy link
Member

@rymut exactly, _ functions are by definition in all nodejs apps including the core of node "private", or not intended to be used. That doesn't mean you can't use them, but you have no support for it and there will be never a documentation of those except for code docs.

So short, no support, use it on your own risk don't complain should it break without notice or major version bump in the future and finally, be prepared to walk on your own, since you will need to figure out those functions functionality and way of working yourself.

@gmahe
Copy link

gmahe commented Jun 22, 2019

One example to update a collection:

exports.up = function(db) {
  return db._run("update", "collectionToUpdate", {
    query: { id: "1123" }, // What you need to find
    update: { title: "myNewTitle", desc: "It works" }, // What you need to change
    options: {}, // Options like e.g: upsert: false,
  });
};

Have a look here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants