Created
July 10, 2011 01:18
-
-
Save s9tpepper/1074128 to your computer and use it in GitHub Desktop.
Using the insert() 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
/* Use a Document object to build the BSON document to save into the database */ | |
const newDocument:Document = new Document(); | |
newDocument.put("name", "Hello from Flash sucka!"); | |
/* Use the insert() method to save. This method does not return anything */ | |
mongo.db("myDatabase").collection("myCollection").insert(newDocument); | |
/* Use a getLastError command to get the status of the last insert attempt. */ | |
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 insert 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