Created
July 24, 2014 18:10
-
-
Save lefloh/70b8bdad7eef12949876 to your computer and use it in GitHub Desktop.
mongo-dart-test
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
import 'dart:async'; | |
import 'package:mongo_dart/mongo_dart.dart'; | |
class MongoTest { | |
Db _db = new Db('mongodb://localhost/test'); | |
insert() { | |
_db.open().then((_) { | |
return _db.collection('foo').insertAll([{ 'foo': 'bar' }]); | |
}).then((_) => _db.close()); | |
} | |
Future find() { | |
return _db.open().then((_) { | |
return _db.collection('foo').find().toList(); | |
}).then((val) { | |
_db.close(); | |
return val; | |
}); | |
} | |
} | |
main() { | |
var mongoTest = new MongoTest(); | |
//mongoTest.insert(); | |
mongoTest.find().then((x) => print(x)); | |
// second call causes NoSuchMethodError: method not found: 'query' | |
//mongoTest.find().then((x) => print(x)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment