api update

This commit is contained in:
tmshv committed 2020-02-15 01:58:42 +03:00
1 parent 502a314c68
commit 99b412ea8d
19 files changed
+684

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
export async function find(collection, query, {sort, skip, limit}) {
const cursor = collection.find(query)
if (sort) cursor.sort(sort)
if (skip) cursor.skip(skip)
if (limit) cursor.limit(limit)
return cursor.toArray()
}
export async function findOne(collection, query) {
return collection.findOne(query)
}
export async function total(collection, query) {
return collection
.find(query)
.count()
}