typed-pocketbase
Advanced tools
Comparing version
@@ -380,3 +380,3 @@ #!/usr/bin/env node | ||
import { dirname, resolve } from "node:path"; | ||
sade("typed-pocketbase", true).version("0.1.0").describe("Generate types for the PocketBase JavaScript SDK").option( | ||
sade("typed-pocketbase", true).version("0.1.1").describe("Generate types for the PocketBase JavaScript SDK").option( | ||
"-u, --url", | ||
@@ -383,0 +383,0 @@ "URL to your hosted pocketbase instance.", |
{ | ||
"name": "typed-pocketbase", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Add types to the PocketBase JavaScript SDK", | ||
@@ -20,2 +20,3 @@ "author": "David Plugge", | ||
"type": "module", | ||
"main": "./dist/client/index.js", | ||
"module": "./dist/client/index.js", | ||
@@ -22,0 +23,0 @@ "types": "./dist/client/index.d.ts", |
@@ -66,4 +66,2 @@ # typed-pocketbase | ||
```ts | ||
import { createOptions } from 'typed-pocketbase'; | ||
const showId = Math.random() < 0.5; | ||
@@ -153,3 +151,3 @@ | ||
The `createOptions` function automatically expands your models: | ||
In `typed-pocketbase` expanding happens automatically when using select. | ||
@@ -206,4 +204,38 @@ ```ts | ||
## Helper methods: | ||
### createSelect | ||
```ts | ||
const select = db.from('posts').createSelect({ | ||
id: true, | ||
content: true, | ||
owner: true, | ||
collectionName: true, | ||
asd: true, | ||
expand: { | ||
owner: { | ||
username: true, | ||
email: true | ||
} | ||
} | ||
}); | ||
``` | ||
### createFilter | ||
```ts | ||
const filter = db | ||
.from('posts') | ||
.createFilter(or(eq('content', 'bla'), eq('published', true))); | ||
``` | ||
### createSort | ||
```ts | ||
const sort = db.from('posts').createSort('+id', '-date'); | ||
``` | ||
## License | ||
[MIT](https://github.com/david-plugge/typed-pocketbase/blob/main/LICENSE) |
88042
0.51%239
15.46%