/* 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") db = conn.getDB("moma") db1 = conn.getDB("moma1") db1.Artworks.drop() db1.createCollection("Artworks") cursor = db.Artworks.find() var n = 0 var docs = [] while(cursor.hasNext()){ doc = cursor.next() doc._id = doc.ObjectID artistArray = [] for(i=0; i