nedb-async
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -12,2 +12,3 @@ import * as Nedb from "nedb"; | ||
asyncRemoveIndex(fieldName: string): Promise<{}>; | ||
asyncLoadDatabase(): Promise<{}>; | ||
} |
@@ -33,3 +33,10 @@ "use strict"; | ||
} | ||
asyncLoadDatabase() { | ||
return new Promise((resolve, reject) => { | ||
this.loadDatabase((err) => { | ||
err ? reject(err) : resolve(true); | ||
}); | ||
}); | ||
} | ||
} | ||
exports.default = AsyncNedb; |
49
index.ts
@@ -11,23 +11,30 @@ import * as Nedb from "nedb"; | ||
} | ||
asyncCount(query: any) { | ||
return promisefy.call(this, 'count', arguments) | ||
asyncCount(query: any) { | ||
return promisefy.call(this, 'count', arguments) | ||
} | ||
asyncFindOne<T>(query: any, projection?: T) { | ||
return promisefy.call(this, 'findOne', arguments) as Promise<T> | ||
} | ||
asyncInsert<T>(newDoc: T) { | ||
return justPromise.call(this, 'insert', arguments) | ||
} | ||
asyncUpdate(query: any, updateQuery: any, options?: Nedb.UpdateOptions) { | ||
return justPromise.call(this, 'update', arguments) | ||
} | ||
asyncRemove(query: any, options?: Nedb.RemoveOptions) { | ||
return justPromise.call(this, 'remove', arguments) | ||
} | ||
asyncEnsureIndex(options: Nedb.EnsureIndexOptions, ) { | ||
return justPromise.call(this, 'ensureIndex', arguments) | ||
} | ||
asyncRemoveIndex(fieldName: string) { | ||
return justPromise.call(this, 'removeIndex', arguments) | ||
} | ||
asyncLoadDatabase() { | ||
return new Promise((resolve, reject) => { | ||
this.loadDatabase((err) => { | ||
err ? reject(err) : resolve(true) | ||
}) | ||
}); | ||
} | ||
} | ||
asyncFindOne<T>(query: any, projection?: T) { | ||
return promisefy.call(this, 'findOne', arguments) as Promise<T> | ||
} | ||
asyncInsert<T>(newDoc: T) { | ||
return justPromise.call(this, 'insert', arguments) | ||
} | ||
asyncUpdate(query: any, updateQuery: any, options?: Nedb.UpdateOptions) { | ||
return justPromise.call(this, 'update', arguments) | ||
} | ||
asyncRemove(query: any, options?: Nedb.RemoveOptions) { | ||
return justPromise.call(this, 'remove', arguments) | ||
} | ||
asyncEnsureIndex(options: Nedb.EnsureIndexOptions,) { | ||
return justPromise.call(this, 'ensureIndex', arguments) | ||
} | ||
asyncRemoveIndex(fieldName: string) { | ||
return justPromise.call(this, 'removeIndex', arguments) | ||
} | ||
} |
{ | ||
"name": "nedb-async", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Promise wrapper for Nedb that makes it possible to use all Nedb all cursor modifiers.", | ||
@@ -5,0 +5,0 @@ "repository": { |
14865
264