Permalink
Browse files

first mongo

  • Loading branch information...
0 parents commit 72791e0e5006941e35191d01d5371142b3bc15f5 blackdog committed Apr 4, 2010
Showing with 580 additions and 0 deletions.
  1. +76 −0 Test.hx
  2. +30 −0 bdog-mongo.haxed
  3. +374 −0 bdog/mongo/Mongo.hx
  4. +100 −0 bdog/mongo/MongoNative.hx
76 Test.hx
@@ -0,0 +1,76 @@
+
+import js.Node;
+import bdog.mongo.Mongo;
+import bdog.mongo.MongoNative;
+
+typedef Woot = {
+ var a:String;
+}
+
+class Test {
+ static var pool:MongoPool;
+
+ public inline static function
+ DB() {
+ return new MongoNative(pool);
+ }
+
+ public static function
+ main() {
+ pool = new MongoPool('localhost',27017,'ritchie',3);
+ easy();
+ }
+
+ public static function
+ easy() {
+
+ DB().col('newish').insert({counter:1,hello:'there'});
+ for (i in 0...10)
+ DB().col('newish').insert({counter:i,hello:'rhere'+i});
+
+ DB().col('newish').count(function(c) {
+ trace('have now '+c);
+ });
+ }
+
+ public static function
+ primitives() {
+
+ for(i in 0...200) {
+
+ new MongoNative(pool).open(function(err,db) {
+ if (err != null) trace(err);
+ trace("opening "+i);
+
+ db.collection('woot',function(err,coll) {
+ coll.find({a:{_lte:3}},function(err,cursor) {
+ cursor.each(function(err,woot:Woot) {
+ // trace(woot);
+ });
+ });
+ });
+
+ db.collection('woot',function(err,coll) {
+ coll.insert({nice:'one laddie'},function(err,doc) {
+ if (err != null) trace(err);
+ //trace(doc);
+ coll.count(function(err,c) {
+ trace("n recs is "+c);
+ db.close();
+ });
+
+
+ });
+ });
+
+ db.createCollection('stuff',function(err,coll) {
+ coll.insert({mystuff:[1,2,3]},function(err,doc) {
+ db.close();
+ });
+ });
+
+ });
+ }
+ }
+
+}
@@ -0,0 +1,30 @@
+
+
+---
+project:
+ website: http://blackdog66.wordpress.com
+ version: 0.1
+ comments: first
+ description: MongoDB for Node.js
+ author: blackdog
+ author-email: blackdog66@gmail.com
+ tags: node.js mongo
+ license: GPL
+ depends: nodejs
+
+---
+
+pack:
+ include: ./
+
+---
+
+build:
+ name: test
+ target: js
+ target-file: test.js
+ class-path: ./
+ /home/blackdog/Projects/hx/node
+ /home/blackdog/Projects/hx/core
+ main-class: Test
+ options: -D nodejs
Oops, something went wrong.

0 comments on commit 72791e0

Please sign in to comment.