Created
July 10, 2011 01:24
-
-
Save s9tpepper/1074133 to your computer and use it in GitHub Desktop.
Using the remove() method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Retrieve the _id property from a document returned by mongodb. */ | |
var objectId:ObjectID = documentRetrievedFromMongo._id; | |
/* Create a selector query using the Document object to specify by _id | |
which document to remove() */ | |
var selector:Document = new Document(); | |
selector.put("_id", objectId); | |
/* Call the remove function, there is no return. */ | |
mongo.db("myDatabase").collection("myCollection").remove(selector); | |
/* Use the getLastError command like with the insert() to check for success. */ | |
mongo.db("myDatabase").runCommand(new Document("getLastError:")).addOnce(onLastError); | |
function onLastError(opReply:OpReply):void | |
{ | |
// The command response document will be in the first element | |
// of the documents Array in the OpReply object. The structure | |
// of the document will depend on the command executed. | |
var document:Object = opReply.documents[0]; | |
// The ok property should equal 1 if the remove was a success. | |
if (1 == document.ok) | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment