Add the documentation with the example how to use _run function
kalkusa opened this issue · comments
_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.
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.
@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.
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