Skip to content

Instantly share code, notes, and snippets.

@devdazed
Created July 21, 2011 18:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdazed/1097861 to your computer and use it in GitHub Desktop.
Save devdazed/1097861 to your computer and use it in GitHub Desktop.
BSON Symbols and Node.JS
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
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();
});
});
});
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