/* This is a JavaScript script for mongodb. It constructs a new version of the Artists collection of the moma database from the one created by mongoimport and the Artists.json files downloaded from the Museum of Modern Art: https://github.com/MuseumofModernArt/collection It makes the following change: The auto-generated _id field is replaced by the ConstituentID in Artists */ conn = new Mongo("mongodb.cs.oberlin.edu") db = conn.getDB("moma") db1 = conn.getDB("moma1") db1.Artists.drop() db1.createCollection("Artists") cursor = db.Artists.find() docs = [] while(cursor.hasNext()){ doc = cursor.next() doc._id = doc.ConstituentID docs.push(doc) } db1.Artists.insertMany(docs)