Skip to content

Instantly share code, notes, and snippets.

@heroic
Created May 9, 2011 10:24
Show Gist options
  • Save heroic/962337 to your computer and use it in GitHub Desktop.
Save heroic/962337 to your computer and use it in GitHub Desktop.
test2
var mongo = require("mongodb"), db = new mongo.Db("test", new mongo.Server("localhost", mongo.Connection.DEFAULT_PORT), {strict: true})
db.open(function(err, db) {
if(err) {
throw new Error(err)
} else {
db.collection("testing", function(err, collection) {
collection.find({}).limit(1).toArray(function(err, users){
user = users[0]
if(err) {
console.log(err.message)
} else if(user) {
user.friends.splice(1,1)
collection.save(user, function(err, doc){
if(err) {
console.log(err.message)
}
})
}
})
})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment