@types/nedb
Advanced tools
Comparing version 0.0.31 to 1.8.0
@@ -1,2 +0,2 @@ | ||
// Type definitions for NeDB | ||
// Type definitions for NeDB 1.8 | ||
// Project: https://github.com/louischatriot/nedb | ||
@@ -6,12 +6,9 @@ // Definitions by: Stefan Steinhart <https://github.com/reppners> | ||
export = NeDBDataStore; | ||
export = Nedb; | ||
export as namespace Nedb; | ||
declare namespace NeDBDataStore { } | ||
declare class NeDBDataStore { | ||
constructor(); | ||
constructor(path:string); | ||
constructor(options:NeDB.DataStoreOptions); | ||
declare class Nedb { | ||
constructor(pathOrOptions?: string | Nedb.DataStoreOptions); | ||
persistence:NeDB.Persistence; | ||
persistence: Nedb.Persistence; | ||
@@ -21,3 +18,3 @@ /** | ||
*/ | ||
loadDatabase(cb?:(err:Error)=>void):void; | ||
loadDatabase(cb?: (err: Error) => void): void; | ||
@@ -27,3 +24,3 @@ /** | ||
*/ | ||
getAllData():Array<any>; | ||
getAllData(): Array<any>; | ||
@@ -34,3 +31,3 @@ | ||
*/ | ||
resetIndexes(newData:any):void; | ||
resetIndexes(newData: any): void; | ||
@@ -46,3 +43,3 @@ /** | ||
*/ | ||
ensureIndex(options:NeDB.EnsureIndexOptions, cb?:(err:Error)=>void):void; | ||
ensureIndex(options: Nedb.EnsureIndexOptions, cb?: (err: Error) => void): void; | ||
@@ -54,3 +51,3 @@ /** | ||
*/ | ||
removeIndex(fieldName:string, cb?:(err:Error)=>void):void; | ||
removeIndex(fieldName: string, cb?: (err: Error) => void): void; | ||
@@ -60,4 +57,3 @@ /** | ||
*/ | ||
addToIndexes<T>(doc:T):void; | ||
addToIndexes<T>(doc:Array<T>):void; | ||
addToIndexes<T>(doc: T | T[]): void; | ||
@@ -67,4 +63,3 @@ /** | ||
*/ | ||
removeFromIndexes<T>(doc:T):void; | ||
removeFromIndexes<T>(doc:Array<T>):void; | ||
removeFromIndexes<T>(doc: T | T[]): void; | ||
@@ -76,4 +71,4 @@ /** | ||
*/ | ||
updateIndexes<T>(oldDoc:T, newDoc:T):void; | ||
updateIndexes<T>(updates:Array<{oldDoc:T; newDoc:T;}>):void; | ||
updateIndexes<T>(oldDoc: T, newDoc: T): void; | ||
updateIndexes<T>(updates: Array<{oldDoc: T; newDoc: T}>): void; | ||
@@ -89,3 +84,3 @@ /** | ||
*/ | ||
getCandidates(query:any):void; | ||
getCandidates(query: any): void; | ||
@@ -96,3 +91,3 @@ /** | ||
*/ | ||
insert<T>(newDoc:T, cb?:(err:Error, document:T)=>void):void; | ||
insert<T>(newDoc: T, cb?: (err: Error, document: T) => void): void; | ||
@@ -103,4 +98,4 @@ /** | ||
*/ | ||
count(query:any, callback:(err:Error, n:number)=>void):void; | ||
count(query:any):NeDB.CursorCount; | ||
count(query: any, callback: (err: Error, n: number) => void): void; | ||
count(query: any): Nedb.CursorCount; | ||
@@ -113,4 +108,4 @@ /** | ||
*/ | ||
find<T>(query:any, projection:T, callback:(err:Error, documents:Array<T>)=>void):void; | ||
find<T>(query:any, projection:T):NeDB.Cursor<T>; | ||
find<T>(query: any, projection: T, callback: (err: Error, documents: Array<T>) => void): void; | ||
find<T>(query: any, projection?: T): Nedb.Cursor<T>; | ||
@@ -122,4 +117,3 @@ /** | ||
*/ | ||
find<T>(query:any, callback:(err:Error, documents:Array<T>)=>void):void; | ||
find<T>(query:any):NeDB.Cursor<T>; | ||
find<T>(query: any, callback: (err: Error, documents: Array<T>) => void): void; | ||
@@ -131,3 +125,3 @@ /** | ||
*/ | ||
findOne<T>(query:any, projection:T, callback:(err:Error, document:T)=>void):void; | ||
findOne<T>(query: any, projection: T, callback: (err: Error, document: T) => void): void; | ||
@@ -138,6 +132,6 @@ /** | ||
*/ | ||
findOne<T>(query:any, callback:(err:Error, document:T)=>void):void; | ||
findOne<T>(query: any, callback: (err: Error, document: T) => void): void; | ||
/** | ||
* Update all docs matching query v1.7.4 and prior signature. | ||
* Update all docs matching query v1.7.4 and prior signature. | ||
* For now, very naive implementation (recalculating the whole database) | ||
@@ -149,27 +143,28 @@ * @param {any} query | ||
* options.upsert If true, document is inserted if the query doesn't match anything | ||
* @param {Function} cb Optional callback, signature: err, | ||
* numReplaced, | ||
* upsert (set to true if the update was in fact an upsert) | ||
* @param {Function} cb Optional callback, signature: err, | ||
* numReplaced, | ||
* upsert (set to true if the update was in fact an upsert) | ||
* | ||
* @api private Use Datastore.update which has the same signature | ||
*/ | ||
update(query:any, updateQuery:any, options?:NeDB.UpdateOptions, cb?:(err:Error, numberOfUpdated:number, upsert:boolean)=>void):void; | ||
/** | ||
* Update all docs matching query v1.8 signature. | ||
* For now, very naive implementation (recalculating the whole database) | ||
* @param {any} query | ||
* @param {any} updateQuery | ||
* @param {Object} options Optional options | ||
* options.multi If true, can update multiple documents (defaults to false) | ||
* options.upsert If true, document is inserted if the query doesn't match anything | ||
* @param {Function} cb Optional callback, signature: err, | ||
* numAffected, | ||
* affectedDocuments (when returnUpdatedDocs is set to true), obj or array | ||
* upsert (set to true if the update was in fact an upsert) | ||
* | ||
* @api private Use Datastore.update which has the same signature | ||
*/ | ||
update<T>(query:any, updateQuery:any, options?:NeDB.UpdateOptions, cb?:(err:Error, numberOfUpdated:number, affectedDocuments:any, upsert:boolean)=>void):void; | ||
update(query: any, updateQuery: any, options?: Nedb.UpdateOptions, cb?: (err: Error, numberOfUpdated: number, upsert: boolean) => void): void; | ||
/** | ||
* Update all docs matching query v1.8 signature. | ||
* For now, very naive implementation (recalculating the whole database) | ||
* @param {any} query | ||
* @param {any} updateQuery | ||
* @param {Object} options Optional options | ||
* options.multi If true, can update multiple documents (defaults to false) | ||
* options.upsert If true, document is inserted if the query doesn't match anything | ||
* @param {Function} cb Optional callback, signature: err, | ||
* numAffected, | ||
* affectedDocuments (when returnUpdatedDocs is set to true), obj or array | ||
* upsert (set to true if the update was in fact an upsert) | ||
* | ||
* @api private Use Datastore.update which has the same signature | ||
*/ | ||
update<T>(query: any, updateQuery: any, options?: Nedb.UpdateOptions, cb?: (err: Error, numberOfUpdated: number, affectedDocuments: any, upsert: boolean) => void): void; | ||
/** | ||
* Remove all docs matching the query | ||
@@ -184,28 +179,41 @@ * For now very naive implementation (similar to update) | ||
*/ | ||
remove(query:any, options:NeDB.RemoveOptions, cb?:(err:Error, n:number)=>void):void; | ||
remove(query:any, cb?:(err:Error, n:number)=>void):void; | ||
remove(query: any, options: Nedb.RemoveOptions, cb?: (err: Error, n: number) => void): void; | ||
remove(query: any, cb?: (err: Error, n: number) => void): void; | ||
} | ||
declare namespace NeDB { | ||
declare namespace Nedb { | ||
interface Cursor<T> { | ||
sort(query:any):Cursor<T>; | ||
skip(n:number):Cursor<T>; | ||
limit(n:number):Cursor<T>; | ||
projection(query:any):Cursor<T>; | ||
exec(callback:(err:Error, documents:Array<T>)=>void):void; | ||
sort(query: any): Cursor<T>; | ||
skip(n: number): Cursor<T>; | ||
limit(n: number): Cursor<T>; | ||
projection(query: any): Cursor<T>; | ||
exec(callback: (err: Error, documents: Array<T>) => void): void; | ||
} | ||
interface CursorCount { | ||
exec(callback:(err:Error, count:number)=>void):void; | ||
exec(callback: (err: Error, count: number) => void): void; | ||
} | ||
interface DataStoreOptions { | ||
filename?:string // Optional, datastore will be in-memory only if not provided | ||
inMemoryOnly?:boolean // Optional, default to false | ||
nodeWebkitAppName?:boolean // Optional, specify the name of your NW app if you want options.filename to be relative to the directory where | ||
autoload?:boolean // Optional, defaults to false | ||
onload?:(error:Error)=>any // Optional, if autoload is used this will be called after the load database with the error object as parameter. If you don't pass it the error will be thrown | ||
afterSerialization?:(line:string)=>string; // (optional): hook you can use to transform data after it was serialized and before it is written to disk. Can be used for example to encrypt data before writing database to disk. This function takes a string as parameter (one line of an NeDB data file) and outputs the transformed string, which must absolutely not contain a \n character (or data will be lost) | ||
beforeDeserialization?:(line:string)=>string; // (optional): reverse of afterSerialization. Make sure to include both and not just one or you risk data loss. For the same reason, make sure both functions are inverses of one another. Some failsafe mechanisms are in place to prevent data loss if you misuse the serialization hooks: NeDB checks that never one is declared without the other, and checks that they are reverse of one another by testing on random strings of various lengths. In addition, if too much data is detected as corrupt, NeDB will refuse to start as it could mean you're not using the deserialization hook corresponding to the serialization hook used before (see below) | ||
corruptAlertThreshold?:number; // (optional): between 0 and 1, defaults to 10%. NeDB will refuse to start if more than this percentage of the datafile is corrupt. 0 means you don't tolerate any corruption, 1 means you don't care | ||
filename?: string // Optional, datastore will be in-memory only if not provided | ||
inMemoryOnly?: boolean // Optional, default to false | ||
nodeWebkitAppName?: boolean // Optional, specify the name of your NW app if you want options.filename to be relative to the directory where | ||
autoload?: boolean // Optional, defaults to false | ||
// Optional, if autoload is used this will be called after the load database with the error object as parameter. If you don't pass it the error will be thrown | ||
onload?: (error: Error) => any | ||
// (optional): hook you can use to transform data after it was serialized and before it is written to disk. | ||
// Can be used for example to encrypt data before writing database to disk. | ||
// This function takes a string as parameter (one line of an NeDB data file) and outputs the transformed string, which must absolutely not contain a \n character (or data will be lost) | ||
afterSerialization?: (line: string) => string; | ||
// (optional): reverse of afterSerialization. | ||
// Make sure to include both and not just one or you risk data loss. | ||
// For the same reason, make sure both functions are inverses of one another. | ||
// Some failsafe mechanisms are in place to prevent data loss if you misuse the serialization hooks: | ||
// NeDB checks that never one is declared without the other, and checks that they are reverse of one another by testing on random strings of various lengths. | ||
// In addition, if too much data is detected as corrupt, | ||
// NeDB will refuse to start as it could mean you're not using the deserialization hook corresponding to the serialization hook used before (see below) | ||
beforeDeserialization?: (line: string) => string; | ||
// (optional): between 0 and 1, defaults to 10%. NeDB will refuse to start if more than this percentage of the datafile is corrupt. | ||
// 0 means you don't tolerate any corruption, 1 means you don't care | ||
corruptAlertThreshold?: number; | ||
} | ||
@@ -227,16 +235,16 @@ | ||
interface RemoveOptions { | ||
multi?:boolean | ||
multi?: boolean | ||
} | ||
interface EnsureIndexOptions { | ||
fieldName:string; | ||
unique?:boolean; | ||
sparse?:boolean; | ||
fieldName: string; | ||
unique?: boolean; | ||
sparse?: boolean; | ||
} | ||
interface Persistence { | ||
compactDatafile():void; | ||
setAutocompactionInterval(interval:number):void; | ||
stopAutocompaction():void; | ||
compactDatafile(): void; | ||
setAutocompactionInterval(interval: number): void; | ||
stopAutocompaction(): void; | ||
} | ||
} |
{ | ||
"name": "@types/nedb", | ||
"version": "0.0.31", | ||
"version": "1.8.0", | ||
"description": "TypeScript definitions for NeDB", | ||
"license": "MIT", | ||
"author": "Stefan Steinhart <https://github.com/reppners>", | ||
"contributors": [ | ||
{ | ||
"name": "Stefan Steinhart", | ||
"url": "https://github.com/reppners" | ||
} | ||
], | ||
"main": "", | ||
@@ -14,4 +19,5 @@ "repository": { | ||
"dependencies": {}, | ||
"typings": "index.d.ts", | ||
"typesPublisherContentHash": "cb5747529ba933b3f1178c34627877e8765f9362d5f72698d6f7fdcb4c242dae" | ||
"peerDependencies": {}, | ||
"typesPublisherContentHash": "35e46d27c3d83077e370a0c7ce7202f98b7ffdbf369f3210d066bf2c370e466d", | ||
"typeScriptVersion": "2.0" | ||
} |
@@ -8,12 +8,10 @@ # Installation | ||
# Details | ||
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/types-2.0/nedb | ||
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/nedb | ||
Additional Details | ||
* Last updated: Mon, 19 Sep 2016 17:28:59 GMT | ||
* File structure: UMD | ||
* Library Dependencies: none | ||
* Module Dependencies: none | ||
* Global values: NeDBDataStore, Nedb | ||
* Last updated: Tue, 14 Mar 2017 22:08:10 GMT | ||
* Dependencies: none | ||
* Global values: Nedb | ||
# Credits | ||
These definitions were written by Stefan Steinhart <https://github.com/reppners>. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
11439
3
202
17