Skip to content

Instantly share code, notes, and snippets.

@Scorpiion
Created September 10, 2015 11:39
Show Gist options
  • Save Scorpiion/44733a13a72d771df1c3 to your computer and use it in GitHub Desktop.
Save Scorpiion/44733a13a72d771df1c3 to your computer and use it in GitHub Desktop.
Future list(String mongodbUri, String database_name, String collection_name) async {
// Default pagination option
var limit = 50;
var skip = 0;
// Create database connection
Db db = new Db('$mongodbUri/$database_name');
// Connect
await db.open();
// Create coll object
var coll = db.collection(collection_name);
// Get all documents
var documents = await coll.find(where.limit(limit).skip(skip)).toList();
// Close db
db.close();
return documents;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment