https://github.com/thegears/geardb
Another local json database.
https://github.com/thegears/geardb
database db json localdb
Last synced: 2 months ago
JSON representation
Another local json database.
- Host: GitHub
- URL: https://github.com/thegears/geardb
- Owner: thegears
- Created: 2023-12-26T15:36:20.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-21T00:42:15.000Z (over 1 year ago)
- Last Synced: 2025-08-27T21:54:43.053Z (10 months ago)
- Topics: database, db, json, localdb
- Language: TypeScript
- Homepage:
- Size: 462 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Another Local JSON Database.





## How to use
```ts
// ES6
import GearDB from 'geardb';
// CommonJS
const GearDB = require('geardb');
const db = new GearDB("db.json"); // path to db.
await db.set("key", "value");
console.log(await db.get("key")); // log 'value'
await db.push("list", "value");
console.log(await db.get("list")); // log ['value']
await db.pull("list", "value");
// -- OR --
await db.pull("list", 0);
console.log(await db.get("list")); // log []
await db.filter("list",(value) => value !== "value");
console.log(await db.get("list")); // log []
// -- find,findAndSet, findAndPush, findAndPull ---
"test" :[
{
"userId": "2121",
"values": [
{
"id": 1,
"value": 122
}
]
}
]
console.log(await db.find("test.userId=2121.values.id=1.value")); // log 122
await db.findAndPush("test.userId=2121.values", { id: 12, value: 1222 }) // in test array, finds element which userId is 2121 and pushes { id: 12, value: 1222 }
await db.findAndSet("test.userId=2121.values.id=1.value", 1222) // in test array, finds element which userId is 2121 and in values array finds element which id is 1 and sets value 1222
await db.findAndSet("test.userId=2121.userId", 1222) // in test array, finds element which userId is 2121 and sets userId 1222
await db.findAndPull("test","userId=2121") // in test array, finds element which userId is 2121 and removes it
await db.findAndPull("test.userId=2121.values","id=1") // in test array, finds element which userId is 2121 and in values array finds element which id is 1 and removes it
```