Skip to content

Commit

Permalink
Feature/add option to delete a lokijs database (#28)
Browse files Browse the repository at this point in the history
* chore: update tsconfigs

* chore: bump versions

* chore: bump libs

* feat: implement deleteDatabase

* feat: return errors from deletion
  • Loading branch information
jkoenig134 authored Apr 5, 2024
1 parent 158cf61 commit c98308e
Show file tree
Hide file tree
Showing 14 changed files with 607 additions and 336 deletions.
886 changes: 567 additions & 319 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
"test:local": "npm run test:local --workspaces --if-present"
},
"devDependencies": {
"@js-soft/eslint-config-ts": "1.6.6",
"@js-soft/license-check": "1.0.8",
"@types/jest": "^29.5.11",
"@types/node": "^20.10.5",
"eslint": "^8.56.0",
"@js-soft/eslint-config-ts": "1.6.7",
"@js-soft/license-check": "1.0.9",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.4",
"eslint": "^8.57.0",
"jest": "^29.7.0",
"prettier": "^3.1.1",
"ts-jest": "^29.1.1",
"prettier": "^3.2.5",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
"typescript": "^5.4.4"
}
}
2 changes: 1 addition & 1 deletion packages/abstractions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@js-soft/docdb-access-abstractions",
"version": "1.0.3",
"version": "1.0.4",
"description": "Database abstractions.",
"homepage": "https://github.com/js-soft/ts-documentdb-access#readme",
"repository": {
Expand Down
1 change: 1 addition & 0 deletions packages/abstractions/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"module": "commonjs",
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "dist",
Expand Down
4 changes: 2 additions & 2 deletions packages/loki/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@js-soft/docdb-access-loki",
"version": "1.0.6",
"version": "1.1.0",
"description": "The LokiJS implementation for the '@js-soft/@js-soft/docdb-access-abstractions' library.",
"homepage": "https://github.com/js-soft/ts-documentdb-access#readme",
"repository": {
Expand All @@ -27,7 +27,7 @@
"testTimeout": 60000
},
"dependencies": {
"@js-soft/docdb-access-abstractions": "1.0.3",
"@js-soft/docdb-access-abstractions": "1.0.4",
"@types/lokijs": "1.5.14",
"lokijs": "1.5.12"
},
Expand Down
16 changes: 16 additions & 0 deletions packages/loki/src/LokiJsConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ export class LokiJsConnection implements IDatabaseConnection {
this.providers.delete(name);
}

public async deleteDatabase(name: string): Promise<void> {
const database = await this.getDatabase(name);

const loki = database["db"];

await new Promise<void>((resolve, reject) =>
loki.deleteDatabase((err) => {
if (err) reject(err);

resolve();
})
);

this.providers.delete(name);
}

public async getDatabase(name: string): Promise<LokiJsCollectionProvider> {
const givenProvider = this.providers.get(name);
if (givenProvider) {
Expand Down
1 change: 1 addition & 0 deletions packages/loki/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"module": "commonjs",
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "dist",
Expand Down
1 change: 1 addition & 0 deletions packages/loki/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"module": "commonjs",
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "dist",
Expand Down
6 changes: 3 additions & 3 deletions packages/mongo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@js-soft/docdb-access-mongo",
"version": "1.1.7",
"version": "1.1.8",
"description": "The MongoDB implementation for the '@js-soft/@js-soft/docdb-access-abstractions' library.",
"homepage": "https://github.com/js-soft/ts-documentdb-access#readme",
"repository": {
Expand Down Expand Up @@ -28,8 +28,8 @@
"testTimeout": 60000
},
"dependencies": {
"@js-soft/docdb-access-abstractions": "1.0.3",
"mongodb": "6.3.0"
"@js-soft/docdb-access-abstractions": "1.0.4",
"mongodb": "6.5.0"
},
"publishConfig": {
"access": "public",
Expand Down
1 change: 1 addition & 0 deletions packages/mongo/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"module": "commonjs",
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "dist",
Expand Down
1 change: 1 addition & 0 deletions packages/mongo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"module": "commonjs",
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "dist",
Expand Down
6 changes: 3 additions & 3 deletions packages/querytranslator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@js-soft/docdb-querytranslator",
"version": "1.1.3",
"version": "1.1.4",
"description": "Parse and pass URL queries to MongoDB and LokiJS query",
"homepage": "https://github.com/js-soft/ts-documentdb-access#readme",
"repository": {
Expand Down Expand Up @@ -31,8 +31,8 @@
"@js-soft/docdb-access-abstractions": "*",
"@js-soft/docdb-access-loki": "*",
"@js-soft/docdb-access-mongo": "*",
"qs": "^6.11.2",
"@types/qs": "^6.9.10"
"qs": "^6.12.0",
"@types/qs": "^6.9.14"
},
"publishConfig": {
"access": "public",
Expand Down
1 change: 1 addition & 0 deletions packages/querytranslator/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"module": "commonjs",
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "dist",
Expand Down
1 change: 1 addition & 0 deletions packages/querytranslator/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"module": "commonjs",
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "dist",
Expand Down

0 comments on commit c98308e

Please sign in to comment.