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
require 'rubygems' | |
require 'mongoid' | |
require 'test/unit' | |
if BSON::BSON_CODER != BSON::BSON_C | |
raise "Please ensure that bson_ext is installed and loaded." | |
end | |
class LionTest < Test::Unit::TestCase | |
DB = "test-mongoid-lion" |
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
var str = ""; | |
for(i=0; i<10000; i++) { | |
str += "0"; | |
} | |
for(n=0; n<100; n++) { | |
for(i=0; i<10000; i++) { | |
db.foo.save({n: "user " + i, data: str}); | |
} | |
} |
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
require 'rubygems' | |
require 'mongoid' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new['foo'] | |
end | |
class Item | |
include Mongoid::Document |
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
/* | |
* Title: tutorial.c | |
* Author: Christopher Triolo | |
* Build & Run: | |
* $ gcc -Isrc --std=c99 tutorial.c /path/to/mongo-c-driver/src/*.c -I /path/to/mongo-c-driver/src/ -o tutorial | |
* $ ./tutorial | |
* connection succeeded | |
* ... | |
* connection closed | |
*/ |
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
#include "test.h" | |
#include "bson.h" | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
int main(){ | |
bson_buffer bb; | |
bson b, sub; | |
bson_iterator it; |
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
require 'rubygems' | |
require 'mongo' | |
# A class to store our DB object | |
class Foo | |
def self.db | |
@@db ||= Mongo::Connection.new['stuff'] | |
end | |
end |
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
require 'mongo' | |
c = Mongo::Connection.new | |
c['test']['nums'].remove | |
c['test']['nums'].save({:n => 2147483635}) | |
1000.times do | |
c['test']['nums'].update({}, {"$inc" => {:n => 1}}) | |
p c['test']['nums'].find_one |
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
require 'rubygems' | |
require 'mongo' | |
@con = Mongo::Connection.new | |
# Instance of Mongo::DB | |
@db = @con['webinar'] | |
# Instance of Mongo::Collection | |
@col = @db['users'] |
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
<?php | |
// connect | |
$m = new Mongo(); | |
// select a database | |
$db = $m->training; | |
$coll = $db->messages; |
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
import com.mongodb.Mongo; | |
import com.mongodb.DB; | |
import com.mongodb.DBCollection; | |
import com.mongodb.BasicDBObject; | |
import com.mongodb.DBObject; | |
import com.mongodb.DBCursor; | |
import com.mongodb.WriteConcern; | |
public class Test { |