generated from cms/tibi-docs
zwischenstand
This commit is contained in:
87
docs/md/server-javascript-kontext/packages/db.md
Normal file
87
docs/md/server-javascript-kontext/packages/db.md
Normal file
@@ -0,0 +1,87 @@
|
||||
## db
|
||||
|
||||
Das Database (Db) Paket stellt Methoden bereit, um Operationen auf einer Datenbank auszuführen. Es umfasst die folgenden Hauptmethoden:
|
||||
|
||||
- `find(colName: string, options?: DbReadOptions): CollectionDocument[]`:
|
||||
Diese Methode ermöglicht das Suchen von Dokumenten in einer bestimmten Sammlung basierend auf den bereitgestellten Optionen.
|
||||
|
||||
- `count(colName: string, options?: DbReadOptions): number`:
|
||||
Diese Methode gibt die Anzahl der Dokumente in einer bestimmten Sammlung zurück, die den Optionen entsprechen.
|
||||
|
||||
- `update(colName: string, id: string, data: CollectionDocument): CollectionDocument:`:
|
||||
Diese Methode aktualisiert das Dokument in einer bestimmten Sammlung, welches die angegebene ID besitzt.
|
||||
|
||||
- `delete(colName: string, id: string): { message: "ok" }:`:
|
||||
Diese Methode entfernt ein Dokument aus einer bestimmten Sammlung, das die angegebene ID besitzt.
|
||||
- `deleteMany(colName: string, options?: DbReadOptions): { message: "ok"; removed: number }:`
|
||||
Diese Methode entfernt mehrere Dokumente aus einer bestimmten Sammlung, die den bereitgestellten Optionen entsprechen.
|
||||
|
||||
- `create(colName: string, data: CollectionDocument): CollectionDocument`
|
||||
Diese Methode fügt ein neues Dokument in eine bestimmte Sammlung ein.
|
||||
|
||||
```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