mongodb - mongo shell same command across multiple collections -


i trying following date conversion on multiple collections:

db.u201409.find().snapshot().foreach(   function (e) {     e.sta = new date(e.start);     e.sto = new date(e.stop);     db.u201409.save(e);   } ) 

as can seen, 1 collection, namely "u201409". format uyyyymm. need execute exact same command collections 201409 until 201604, u201409, u201410, u201411, u201412, u201501, ..., u201604.

is possible using shell script, , if so, how can accomplished?

the mongo shell command language javascript, write javascript:

var = ["u201401", "u201402"...] (var = 0; < a.length; i++) {     db[a[i]].find().snapshot().foreach(         ...     ) } 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -