packages start...
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
## db
|
||||
|
||||
Das Database (Db) Paket stellt Methoden bereit, um Operationen auf einer Datenbank auszuführen. Es umfasst die folgenden Hauptmethoden:
|
||||
|
||||
- find(collection: string, query: object, options?: object): Diese Methode ermöglicht das Suchen von Dokumenten in einer bestimmten Sammlung basierend auf einer Query. Optional können Sie auch Optionen wie Limit, Skip, Sort, usw. angeben.
|
||||
|
||||
- findOne(collection: string, query: object, options?: object): Ähnlich wie die find Methode, aber sie gibt nur das erste Dokument zurück, das die Query erfüllt.
|
||||
|
||||
- insert(collection: string, document: object): Diese Methode fügt ein neues Dokument in eine bestimmte Sammlung ein.
|
||||
|
||||
- update(collection: string, query: object, update: object, options?: object): Diese Methode aktualisiert Dokumente in einer bestimmten Sammlung, die eine Query erfüllt. Sie können auch optionale Parameter wie upsert und multi verwenden.
|
||||
|
||||
- remove(collection: string, query: object, options?: object): Diese Methode entfernt Dokumente aus einer bestimmten Sammlung, die eine Query erfüllen. Optionale Parameter wie justOne können verwendet werden.
|
||||
|
||||
- count(collection: string, query: object): Diese Methode gibt die Anzahl der Dokumente in einer bestimmten Sammlung zurück, die eine Query erfüllen.
|
||||
|
||||
```ts
|
||||
interface DbPackage {
|
||||
/**
|
||||
* read results from a collection
|
||||
*
|
||||
* @param colName collection name
|
||||
* @param options options map
|
||||
*/
|
||||
find(colName: string, options?: DbReadOptions): CollectionDocument[]
|
||||
|
||||
/**
|
||||
* read count of documents for filter from a collection
|
||||
*
|
||||
* @param colName collection name
|
||||
* @param options options map (only filter is valid)
|
||||
*/
|
||||
count(colName: string, options?: DbReadOptions): number
|
||||
|
||||
/**
|
||||
* create a document in a collection
|
||||
*
|
||||
* @param colName collection name
|
||||
* @param data data map
|
||||
*/
|
||||
create(colName: string, data: CollectionDocument): CollectionDocument
|
||||
|
||||
/**
|
||||
* update a document in a collection
|
||||
*
|
||||
* @param colName collection name
|
||||
* @param id id of entry
|
||||
* @param data new/changed data
|
||||
*/
|
||||
update(colName: string, id: string, data: CollectionDocument): CollectionDocument
|
||||
|
||||
/**
|
||||
* deletes one document by id from collection
|
||||
*
|
||||
* @param colName collection name
|
||||
* @param id id of entry
|
||||
*/
|
||||
delete(colName: string, id: string): { message: "ok" }
|
||||
|
||||
/**
|
||||
* deletes documents by filter from collection
|
||||
*
|
||||
* @param colName collection name
|
||||
* @param options options map, only filter valid
|
||||
*/
|
||||
deleteMany(colName: string, options?: DbReadOptions): { message: "ok"; removed: number }
|
||||
}
|
||||
|
||||
interface DbReadOptions {
|
||||
filter?: {
|
||||
[key: string]: any
|
||||
}
|
||||
selector?: {
|
||||
[key: string]: any
|
||||
}
|
||||
projection?: string
|
||||
offset?: number
|
||||
limit?: number
|
||||
sort?: string[]
|
||||
pipelineMod?: (pipe: { [key: string]: any }[]) => { [key: string]: any }[]
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user