Created
July 21, 2011 18:39
-
-
Save devdazed/1097861 to your computer and use it in GitHub Desktop.
BSON Symbols and Node.JS
This file contains 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
require 'mongo' | |
@db = Mongo::Connection.new['test'] | |
@symbol_coll = @db['bson_symbols'] | |
@string_coll = @db['bson_string'] | |
[@symbol_coll, @string_coll].each{|c| c.remove } | |
3.times do |i| | |
@symbol_coll.insert({'foo' => [:a, :b, :c, :d]}) | |
end | |
3.times do |i| | |
@string_coll.insert({'foo' => ['a', 'b', 'c', 'd']}) | |
end |
This file contains 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
var MongoDB = require('mongodb'), | |
client = new MongoDB.Db('test', new MongoDB.Server('localhost',27017), {native_parser:true}); | |
client.open(function(err, db){ | |
db.collection('bson_string', function(err, coll){ | |
coll.find().toArray(function(err, results){ | |
console.log(results); | |
client.close(); | |
}); | |
}); | |
}); |
This file contains 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
var MongoDB = require('mongodb'), | |
client = new MongoDB.Db('test', new MongoDB.Server('localhost',27017), {native_parser:true}); | |
client.open(function(err, db){ | |
db.collection('bson_symbols', function(err, coll){ | |
coll.find().toArray(function(err, results){ | |
//this is bad news | |
console.log(results); | |
client.close(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment