Skip to content

Commit

Permalink
🔥feat: v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
r-rajaneesh committed Dec 17, 2022
1 parent ef53a1b commit a28554b
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 57 deletions.
22 changes: 6 additions & 16 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
## 0.0.1.beta-0

- First release named dat-db

## 0.0.2.beta-0

- Renamed from dat-db to quipodb
- Added a readme
- Added document
- Added changelogs
- Added a nice logo (stole it from flaticon)

## 1.0.0

- Changed `setDoc` to `createDoc`
- Added `hasDoc`
- Moved DB function into a new class
- First release of @quipodb/core, @quipodb/sqlite, @quipodb/firestore, @quipodb/json

## 1.0.1

- Added atomic setters for `updateDoc`
- Fixed bug in @quipodb/json that will not update the data

## 1.0.2

- Fixed bug in @quipodb/sqlite where `updateDoc` command does not update the data
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "quipodb",
"name": "@quipodb/main",
"version": "1.0.0",
"type": "module",
"scripts": {
Expand All @@ -26,21 +26,17 @@
"store"
],
"license": "ISC",
"workspaces": [
"/packages/*"
],
"dependencies": {
"@quipodb/steno": "^1.0.0",
"axios": "^1.1.3",
"better-sqlite3": "^8.0.1",
"esdoc-standard-plugin": "^1.0.0",
"firebase": "^9.11.0",
"firebase-admin": "^11.0.1",
"fs-extra": "^10.1.0",
"is-what": "^4.1.7",
"knex": "^2.3.0",
"lodash": "^4.17.21",
"merge-anything": "^5.0.4",
"sqlite3": "^5.1.2"
"merge-anything": "^5.0.4"
},
"devDependencies": {
"@types/better-sqlite3": "^7.6.2",
Expand Down
1 change: 0 additions & 1 deletion packages/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ interface Collection {
createDoc(data: document | document[], cb?: Function): Promise<any> | any;
deleteDoc(data: document | fn, cb?: Function): Promise<any> | any;
findDoc(data: document | fn, cb?: Function): document;
hasDoc(data: document | fn, cb?: Function): boolean;
getRaw(): any;
updateDoc(refData: document, data: document | fn, cb?: Function): Promise<any> | any;
updateRaw(refData: document | fn, cb?: Function): updateRawCB;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"@quipodb/core","version":"1.0.0","type":"module","main":"./dist/index.js","typings":"./dist/index.d.ts","scripts":{"build":"tsc index.ts -t esnext -m esnext -d --allowSyntheticDefaultImports --moduleResolution node --outDir ./dist","publish-beta-public":"npm publish --tag beta --registry=https://registry.npmjs.com","publish-beta-private":"npm publish --tag beta","publish-public":"npm publish --registry=https://registry.npmjs.com","publish-private":"npm publish"},"author":{"name":"Rajaneesh R","email":"rajaneeshr@proton.me","url":"https://r-rajaneesh.vercel.app"},"keywords":["quipodb","db","database","sqlite","ttl","key","value","store"],"dependencies":{"lodash":"^4.17.21","merge-anything":"^5.0.4"},"devDependencies":{"@types/lodash":"^4.14.182","@types/node":"^18.6.1","typescript":"^4.8.3"}}
{"name":"@quipodb/core","version":"1.0.1","type":"module","main":"./dist/index.js","typings":"./dist/index.d.ts","scope":"@quipodb","private":false,"scripts":{"build":"tsc index.ts -t esnext -m esnext -d --allowSyntheticDefaultImports --moduleResolution node --outDir ./dist","publish-beta-public":"npm publish --tag beta --registry=https://registry.npmjs.com","publish-beta-private":"npm publish --tag beta","publish-public":"npm publish --access public --registry=https://registry.npmjs.com ","publish-private":"npm publish"},"author":{"name":"Rajaneesh R","email":"rajaneeshr@proton.me","url":"https://r-rajaneesh.vercel.app"},"keywords":["quipodb","db","database","sqlite","ttl","key","value","store"],"dependencies":{"lodash":"^4.17.21","merge-anything":"^5.0.4"},"devDependencies":{"@types/lodash":"^4.14.182","@types/node":"^18.6.1","typescript":"^4.8.3"}}
2 changes: 1 addition & 1 deletion packages/firestore/package.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"@quipodb/firestore","version":"1.0.0","description":"Firestore provider for this package","type":"module","main":"./dist/index.js","typings":"./dist/index.d.ts","scripts":{"build":"tsc index.ts -t esnext -m esnext -d --allowSyntheticDefaultImports --moduleResolution node --outDir ./dist","publish-beta-public":"npm publish --tag beta --registry=https://registry.npmjs.com","publish-beta-private":"npm publish --tag beta","publish-public":"npm publish --registry=https://registry.npmjs.com","publish-private":"npm publish"},"keywords":["firestore","quipodb","db","database","provider"],"author":{"name":"Rajaneesh R","email":"rajaneeshr@proton.me","url":"https://r-rajaneesh.vercel.app"},"license":"ISC","dependencies":{"firebase-admin":"^11.0.1"},"devDependencies":{"@types/lodash":"^4.14.182","@types/node":"^18.6.1","typescript":"^4.8.3"}}
{"name":"@quipodb/firestore","version":"1.0.1","description":"Firestore provider for this package","type":"module","main":"./dist/index.js","typings":"./dist/index.d.ts","scripts":{"build":"tsc index.ts -t esnext -m esnext -d --allowSyntheticDefaultImports --moduleResolution node --outDir ./dist","publish-beta-public":"npm publish --tag beta --registry=https://registry.npmjs.com","publish-beta-private":"npm publish --tag beta","publish-public":"npm publish --registry=https://registry.npmjs.com --access public","publish-private":"npm publish"},"keywords":["firestore","quipodb","db","database","provider"],"author":{"name":"Rajaneesh R","email":"rajaneeshr@proton.me","url":"https://r-rajaneesh.vercel.app"},"license":"ISC","dependencies":{"firebase-admin":"^11.0.1"},"devDependencies":{"@types/lodash":"^4.14.182","@types/node":"^18.6.1","typescript":"^4.8.3"}}
29 changes: 22 additions & 7 deletions packages/json/dist/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
import _ from "lodash";
import fs from "fs-extra";
import steno from "@quipodb/steno";
export class JsonStore {
collectionName;
storage;
constructor(options) {
fs.ensureDirSync(options.path.replace(/.+(\.).+$/g, ""));
fs.ensureFileSync(options.path);
this.storage = fs.readJSONSync(options.path) ?? {};
setInterval(() => {
new steno(options.path).write(JSON.stringify(this.storage));
}, 1000);
if (!fs.existsSync(options.path)) {
if (options.path.replace(/.+(\.).+$/g, ""))
fs.ensureDirSync(options.path.replace(/.+(\.).+$/g, ""));
fs.ensureFileSync(options.path);
fs.writeJSONSync(options.path, {});
}
try {
this.storage = fs.readJSONSync(options.path) ?? {};
}
catch {
fs.writeJSONSync(options.path, {});
this.storage = fs.readJSONSync(options.path) ?? {};
}
process
.prependListener("exit", (code) => {
fs.writeJSONSync(options.path, this.storage);
process.exit(1);
})
.prependListener("beforeExit", (code) => {
fs.writeJSONSync(options.path, this.storage);
process.exit(1);
});
}
async createCollectionProvider(collectionName, cb = () => { }) {
this.collectionName = collectionName;
Expand Down
27 changes: 20 additions & 7 deletions packages/json/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import _ from "lodash";
import fs from "fs-extra";
import steno from "@quipodb/steno";
type fn = (data: Object[] | Object) => void;
interface document {
[key: string]: string | number | Object | Array<any> | any;
Expand All @@ -15,12 +14,26 @@ export class JsonStore {
private collectionName: string;
private storage: storage;
constructor(options: JsonStoreOptions) {
fs.ensureDirSync(options.path.replace(/.+(\.).+$/g, ""));
fs.ensureFileSync(options.path);
this.storage = fs.readJSONSync(options.path) ?? {};
setInterval(() => {
new steno(options.path).write(JSON.stringify(this.storage));
}, 1000);
if (!fs.existsSync(options.path)) {
if (options.path.replace(/.+(\.).+$/g, "")) fs.ensureDirSync(options.path.replace(/.+(\.).+$/g, ""));
fs.ensureFileSync(options.path);
fs.writeJSONSync(options.path, {});
}
try {
this.storage = fs.readJSONSync(options.path) ?? {};
} catch {
fs.writeJSONSync(options.path, {});
this.storage = fs.readJSONSync(options.path) ?? {};
}
process
.prependListener("exit", (code) => {
fs.writeJSONSync(options.path, this.storage);
process.exit(1);
})
.prependListener("beforeExit", (code) => {
fs.writeJSONSync(options.path, this.storage);
process.exit(1);
});
}
public async createCollectionProvider(collectionName: string, cb: Function = () => {}) {
this.collectionName = collectionName;
Expand Down
2 changes: 1 addition & 1 deletion packages/json/package.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"@quipodb/json","version":"1.0.0","type":"module","scripts":{"build":"tsc index.ts -t esnext -m esnext -d --allowSyntheticDefaultImports --moduleResolution node --outDir ./dist","build-packages":"cd packages/core && npm run build && cd.. && cd.. && cd packages/firestore && npm run build && cd.. && cd.. && cd packages/sqlite && npm run build && cd.. && cd..","publish-beta-public":"npm publish --tag beta --registry=https://registry.npmjs.com --workspaces","publish-beta-private":"npm publish --tag beta --workspaces","publish-public":"npm publish --registry=https://registry.npmjs.com --workspaces","publish-private":"npm publish --workspaces"},"author":{"name":"Rajaneesh R","email":"rajaneeshr@proton.me","url":"https://r-rajaneesh.vercel.app"},"keywords":["quipodb","db","database","sqlite","ttl","key","value","store"],"license":"ISC","dependencies":{"@quipodb/steno":"^1.0.0","fs-extra":"^10.1.0","lodash":"^4.17.21"},"devDependencies":{"@types/fs-extra":"^9.0.13","@types/lodash":"^4.14.186","@types/node":"^18.11.3","typescript":"^4.8.4"}}
{"name":"@quipodb/json","version":"1.0.1","type":"module","main":"./dist/index.js","scripts":{"build":"tsc index.ts -t esnext -m esnext -d --allowSyntheticDefaultImports --moduleResolution node --outDir ./dist","build-packages":"cd packages/core && npm run build && cd.. && cd.. && cd packages/firestore && npm run build && cd.. && cd.. && cd packages/sqlite && npm run build && cd.. && cd..","publish-beta-public":"npm publish --tag beta --registry=https://registry.npmjs.com --workspaces","publish-beta-private":"npm publish --tag beta --workspaces","publish-public":"npm publish --registry=https://registry.npmjs.com --access public","publish-private":"npm publish --workspaces"},"author":{"name":"Rajaneesh R","email":"rajaneeshr@proton.me","url":"https://r-rajaneesh.vercel.app"},"keywords":["quipodb","db","database","sqlite","ttl","key","value","store"],"license":"ISC","dependencies":{"fs-extra":"^10.1.0","lodash":"^4.17.21"},"devDependencies":{"@types/fs-extra":"^9.0.13","@types/lodash":"^4.14.186","@types/node":"^18.11.3","typescript":"^4.8.4"}}
4 changes: 2 additions & 2 deletions packages/sqlite/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ interface document {
}
declare class Sqlite {
sqlite: sqlite.Database;
options: sqliteConstructor;
collectionName: String;
private options;
private collectionName;
primaryKey: String;
constructor(options: sqliteConstructor);
private mapValues;
Expand Down
9 changes: 4 additions & 5 deletions packages/sqlite/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ class Sqlite {
});
this.sqlite.prepare(`INSERT INTO ${this.collectionName} (${KEYS.join(", ")}) VALUES (${VALUES.map((v) => (v = "(?)")).join(", ")})`).run(VALUES);
}
else {
if (docs === data)
return;
this.updateDocProvider(docs, data);
}
}
catch (error) {
if (this.options.dev)
Expand All @@ -107,6 +102,8 @@ class Sqlite {
result.forEach((res, i) => {
Object.values(res).forEach((r, ri) => {
try {
if (typeof r === "string" && r.startsWith("'") && r.endsWith("'"))
r = r.replace("'", "").split("").reverse().join("").replace("'", "").split("").reverse().join("");
res[`${Object.keys(res)[ri]}`] = JSON.parse(r);
}
catch {
Expand Down Expand Up @@ -136,6 +133,8 @@ class Sqlite {
return undefined;
Object.values(result).forEach((r, ri) => {
try {
if (typeof r === "string" && r.startsWith("'") && r.endsWith("'"))
r = r.replace("'", "").split("").reverse().join("").replace("'", "").split("").reverse().join("");
result[`${Object.keys(result)[ri]}`] = JSON.parse(r);
}
catch {
Expand Down
15 changes: 8 additions & 7 deletions packages/sqlite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ interface storage {
[collectioName: string]: document[];
}
class Sqlite {
sqlite: sqlite.Database;
options: sqliteConstructor;
collectionName: String;
primaryKey: String;
public sqlite: sqlite.Database;
private options: sqliteConstructor;
private collectionName: String;
public primaryKey: String;
constructor(options: sqliteConstructor) {
this.options = options;
this.options.path ??= "./databases/index.sqlite";
Expand Down Expand Up @@ -73,9 +73,6 @@ class Sqlite {
if (!COLUMNS.map((v: any) => v.name).includes(key)) this.createColumnProvider(key, this.typeof(VALUES[i]));
});
this.sqlite.prepare(`INSERT INTO ${this.collectionName} (${KEYS.join(", ")}) VALUES (${VALUES.map((v) => (v = "(?)")).join(", ")})`).run(VALUES);
} else {
if (docs === data) return;
this.updateDocProvider(docs, data);
}
} catch (error) {
if (this.options.dev) console.log(error);
Expand All @@ -98,6 +95,8 @@ class Sqlite {
result.forEach((res: Object, i: number) => {
Object.values(res).forEach((r: any, ri: number) => {
try {
if (typeof r === "string" && r.startsWith("'") && r.endsWith("'"))
r = r.replace("'", "").split("").reverse().join("").replace("'", "").split("").reverse().join("");
res[`${Object.keys(res)[ri]}`] = JSON.parse(r);
} catch {
res[`${Object.keys(res)[ri]}`] = r;
Expand All @@ -123,6 +122,8 @@ class Sqlite {
if (!result) return undefined;
Object.values(result).forEach((r: any, ri: number) => {
try {
if (typeof r === "string" && r.startsWith("'") && r.endsWith("'"))
r = r.replace("'", "").split("").reverse().join("").replace("'", "").split("").reverse().join("");
result[`${Object.keys(result)[ri]}`] = JSON.parse(r);
} catch {
result[`${Object.keys(result)[ri]}`] = r;
Expand Down
2 changes: 1 addition & 1 deletion packages/sqlite/package.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"@quipodb/sqlite","version":"1.0.0","description":"Sqlite provider for this package","type":"module","main":"./dist/index.js","typings":"./dist/index.d.ts","scripts":{"build":"tsc index.ts -t esnext -m esnext -d --allowSyntheticDefaultImports --moduleResolution node --outDir ./dist","publish-beta-public":"npm publish --tag beta --registry=https://registry.npmjs.com","publish-beta-private":"npm publish --tag beta","publish-public":"npm publish --registry=https://registry.npmjs.com","publish-private":"npm publish"},"keywords":["sqlite","quipodb","db","database","provider"],"author":{"name":"Rajaneesh R","email":"rajaneeshr@proton.me","url":"https://r-rajaneesh.vercel.app"},"license":"ISC","dependencies":{"better-sqlite3":"^7.6.2","fs-extra":"^10.1.0"},"devDependencies":{"@types/better-sqlite3":"^7.6.0","@types/fs-extra":"^9.0.13","@types/lodash":"^4.14.182","@types/node":"^18.6.1","typescript":"^4.8.3"}}
{"name":"@quipodb/sqlite","version":"1.0.1","description":"Sqlite provider for this package","type":"module","main":"./dist/index.js","typings":"./dist/index.d.ts","scripts":{"build":"tsc index.ts -t esnext -m esnext -d --allowSyntheticDefaultImports --moduleResolution node --outDir ./dist","publish-beta-public":"npm publish --tag beta --registry=https://registry.npmjs.com","publish-beta-private":"npm publish --tag beta","publish-public":"npm publish --registry=https://registry.npmjs.com --access public","publish-private":"npm publish"},"keywords":["sqlite","quipodb","db","database","provider"],"author":{"name":"Rajaneesh R","email":"rajaneeshr@proton.me","url":"https://r-rajaneesh.vercel.app"},"license":"ISC","dependencies":{"better-sqlite3":"^7.6.2","fs-extra":"^10.1.0"},"devDependencies":{"@types/better-sqlite3":"^7.6.0","@types/fs-extra":"^9.0.13","@types/lodash":"^4.14.182","@types/node":"^18.6.1","typescript":"^4.8.3"}}
2 changes: 1 addition & 1 deletion packages/steno/package.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"@quipodb/steno","version":"1.0.0","type":"module","scripts":{"build":"tsc index.ts -t esnext -m esnext -d --allowSyntheticDefaultImports --moduleResolution node --outDir ./dist","build-packages":"cd packages/core && npm run build && cd.. && cd.. && cd packages/firestore && npm run build && cd.. && cd.. && cd packages/sqlite && npm run build && cd.. && cd..","publish-beta-public":"npm publish --tag beta --registry=https://registry.npmjs.com --workspaces","publish-beta-private":"npm publish --tag beta --workspaces","publish-public":"npm publish --registry=https://registry.npmjs.com --workspaces","publish-private":"npm publish --workspaces"},"author":{"name":"Rajaneesh R","email":"rajaneeshr@proton.me","url":"https://r-rajaneesh.vercel.app"},"license":"ISC","devDependencies":{"@types/node":"^18.11.3","typescript":"^4.8.4"}}
{"name":"@quipodb/steno","version":"1.0.1","type":"module","main":"./dist/index.js","scripts":{"build":"tsc index.ts -t esnext -m esnext -d --allowSyntheticDefaultImports --moduleResolution node --outDir ./dist","build-packages":"cd packages/core && npm run build && cd.. && cd.. && cd packages/firestore && npm run build && cd.. && cd.. && cd packages/sqlite && npm run build && cd.. && cd..","publish-beta-public":"npm publish --tag beta --registry=https://registry.npmjs.com --workspaces","publish-beta-private":"npm publish --tag beta --workspaces","publish-public":"npm publish --registry=https://registry.npmjs.com --access public","publish-private":"npm publish --workspaces"},"author":{"name":"Rajaneesh R","email":"rajaneeshr@proton.me","url":"https://r-rajaneesh.vercel.app"},"license":"ISC","devDependencies":{"@types/node":"^18.11.3","typescript":"^4.8.4"}}

0 comments on commit a28554b

Please sign in to comment.