/* This is a JavaScript script for mongodb. It constructs a new version of the Artworks collection of the moma database from the one created by mongoimport and the Artworks.json file downloaded from the Museum of Modern Art: https://github.com/MuseumofModernArt/collection It makes the following changes: The auto-generated _id field is replaced by the ObjectID field The parallel arrays representing Artist, ConstituentID, etc. are replaced by an array of embedded documents */ conn = new Mongo("mongodb.cs.oberlin.edu") db1 = conn.getDB("moma1") db2 = conn.getDB("moma2") db2.Artworks.drop() db2.createCollection("Artworks") cursor = db1.Artworks.find() //cursor = db1.Artworks.find({ $where : function(){ return this.Artist.length>2 } }).limit(20) // I used this for testing var n = 0 var docs = [] while(cursor.hasNext()){ doc = cursor.next() doc._id = doc.ObjectID artistArray = [] for(i=0; i