Skip to content

Commit 5001144

Browse files
authored
Merge pull request #15 from crashmax-dev/lodash
feat(packages): add `@stenodb/lodash`
2 parents 4835cfb + a45ea06 commit 5001144

36 files changed

+301
-388
lines changed

examples/with-browser-lodash/index.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/with-browser-lodash/package.json

Lines changed: 0 additions & 23 deletions
This file was deleted.

examples/with-browser-lodash/src/index.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

examples/with-browser-lodash/src/storage.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.

examples/with-browser-lodash/src/vite-env.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/with-browser-lodash/tsconfig.json

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "with-node-lodash",
2+
"name": "with-lodash",
33
"type": "module",
44
"private": true,
55
"scripts": {
@@ -8,13 +8,12 @@
88
"build": "del-cli dist && tsc"
99
},
1010
"dependencies": {
11+
"@stenodb/lodash": "workspace:*",
1112
"@stenodb/node": "workspace:*",
1213
"class-transformer": "0.5.1",
13-
"lodash": "4.17.21",
1414
"reflect-metadata": "0.1.13"
1515
},
1616
"devDependencies": {
17-
"@types/node": "18.11.19",
18-
"@types/lodash": "4.14.191"
17+
"@types/node": "18.11.19"
1918
}
2019
}

examples/with-lodash/src/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import 'reflect-metadata'
2+
import { dirname, resolve } from 'node:path'
3+
import { fileURLToPath } from 'node:url'
4+
import { NodeLodash } from '@stenodb/lodash'
5+
import { AsyncAdapter, NodeProvider } from '@stenodb/node'
6+
import { User, Users } from './entities.js'
7+
8+
const path = resolve(dirname(fileURLToPath(import.meta.url)), '..', 'database')
9+
const initialData = new Users(new User(1, 'John Doe'))
10+
const adapter = new AsyncAdapter('users', Users, initialData)
11+
const provider = new NodeProvider({ path })
12+
13+
const database = new NodeLodash(await provider.create(adapter))
14+
await database.read()
15+
16+
function findUserById(id: number) {
17+
return database.data.get('users').find({ id }).value()
18+
}
19+
20+
console.log(findUserById(1))

0 commit comments

Comments
 (0)