Skip to content

Instantly share code, notes, and snippets.

@s9tpepper
Created July 10, 2011 00:10
Show Gist options
  • Save s9tpepper/1074085 to your computer and use it in GitHub Desktop.
Save s9tpepper/1074085 to your computer and use it in GitHub Desktop.
Document object
/* The Document object is used to represent BSON documents
and queries to perform mongodb operations. An empty BSON
document is just a blank Document instance */
var document:Document = new Document();
/* Documents whose properties are all String and number
type values can be created inline using the Document
constructor, {"hello":"world", "type":"message"} is
written inline as below */
var inlineDoc:Document = new Document("hello:world", "type:message");
/* Complex documents can be created using the put() method.
This is useful for creating command objects or for
creating find() modifiers */
var complex:Document = new Document("_id:1", "name:complexDoc");
complex.put("document", inlineDoc);
complex.put("points", 1000);
/* Some utilities for working with the Document object are
coming in the very near future (0.2) */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment