galileo_mongo

Last updated:

0 purchases

galileo_mongo Image
galileo_mongo Images
Add to Cart

Description:

galileo mongo

galileo_mongo #


MongoDB-enabled services for the Galileo framework.
Installation #
Add the following to your pubspec.yaml:
dependencies:
galileo_mongo: ^2.0.0
copied to clipboard
Usage #
This library exposes one main class: MongoService.
Model #
Model is class with no real functionality; however, it represents a basic document, and your services should host inherited classes.
Other Galileo service providers host Model as well, so you will easily be able to modify your application if you ever switch databases.
class User extends Model {
String username;
String password;
}

main() async {
var db = new Db('mongodb://localhost:27017/local');
await db.open();

var service = app.use('/api/users', new MongoService(db.collection("users")));

service.afterCreated.listen((event) {
print("New user: ${event.result}");
});
}
copied to clipboard
MongoService #
This class interacts with a DbCollection (from mongo_dart) and serializing data to and from Maps.
Querying #
You can query these services as follows:
/path/to/service?foo=bar
copied to clipboard
The above will query the database to find records where 'foo' equals 'bar'.
The former will sort result in ascending order of creation, and so will the latter.
List queried = await MyService.index({r"$query": where.id(new ObjectId.fromHexString("some hex string"})));
copied to clipboard
And, of course, you can use mongo_dart queries. Just pass it as query within params.
See the tests for more usage examples.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.