neoorm 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/render.d.ts.map +1 -1
- package/dist/docs/render.js +316 -43
- package/dist/docs/render.js.map +1 -1
- package/dist/docs/search.d.ts +17 -0
- package/dist/docs/search.d.ts.map +1 -0
- package/dist/docs/search.js +191 -0
- package/dist/docs/search.js.map +1 -0
- package/dist/docs/server.d.ts +4 -0
- package/dist/docs/server.d.ts.map +1 -1
- package/dist/docs/server.js +15 -2
- package/dist/docs/server.js.map +1 -1
- package/dist/runtime/query/compile.d.ts +7 -5
- package/dist/runtime/query/compile.d.ts.map +1 -1
- package/dist/runtime/query/compile.js +39 -70
- package/dist/runtime/query/compile.js.map +1 -1
- package/dist/runtime/query/find.d.ts +3 -0
- package/dist/runtime/query/find.d.ts.map +1 -1
- package/dist/runtime/query/find.js +23 -13
- package/dist/runtime/query/find.js.map +1 -1
- package/dist/runtime/query/projection.d.ts +3 -1
- package/dist/runtime/query/projection.d.ts.map +1 -1
- package/dist/runtime/query/projection.js +21 -8
- package/dist/runtime/query/projection.js.map +1 -1
- package/dist/runtime/query/relation-planner.d.ts +1 -0
- package/dist/runtime/query/relation-planner.d.ts.map +1 -1
- package/dist/runtime/query/relation-planner.js +7 -8
- package/dist/runtime/query/relation-planner.js.map +1 -1
- package/dist/runtime/types.d.ts +14 -4
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/schema/relation-types.d.ts +17 -9
- package/dist/schema/relation-types.d.ts.map +1 -1
- package/dist/schema/types.d.ts +4 -0
- package/dist/schema/types.d.ts.map +1 -1
- package/docs/cli.md +2 -0
- package/docs/examples.md +4 -3
- package/docs/queries.md +26 -11
- package/docs/schema.md +1 -1
- package/package.json +1 -1
package/docs/cli.md
CHANGED
|
@@ -90,6 +90,8 @@ Options:
|
|
|
90
90
|
- `-H, --host <host>` — host to bind (default: `127.0.0.1`)
|
|
91
91
|
- `--open` — open the docs site in your default browser
|
|
92
92
|
|
|
93
|
+
The sidebar includes a search box with live results across all documentation pages.
|
|
94
|
+
|
|
93
95
|
## `neoorm db push`
|
|
94
96
|
|
|
95
97
|
Push the current snapshot schema to the database without going through the migration ledger.
|
package/docs/examples.md
CHANGED
|
@@ -367,19 +367,20 @@ const rows = await db.sql`
|
|
|
367
367
|
|
|
368
368
|
## API responses (`strip`)
|
|
369
369
|
|
|
370
|
-
|
|
370
|
+
Hidden columns are omitted from default queries. For login, use `includeHidden: true`, verify, then strip before sending JSON:
|
|
371
371
|
|
|
372
372
|
```ts
|
|
373
373
|
const user = await db.users.findFirst({
|
|
374
374
|
where: { email: input.email },
|
|
375
|
+
includeHidden: true,
|
|
375
376
|
});
|
|
376
377
|
|
|
377
378
|
if (!user || !verifyPassword(input.password, user.password)) {
|
|
378
379
|
throw new Error("Invalid credentials");
|
|
379
380
|
}
|
|
380
381
|
|
|
381
|
-
return user.strip(); //
|
|
382
|
-
return user.strip({
|
|
382
|
+
return user.strip(); // plain object without password
|
|
383
|
+
return user.strip({ refreshToken: true }); // hidden + extra fields
|
|
383
384
|
```
|
|
384
385
|
|
|
385
386
|
`.strip()` is non-enumerable and returns a plain object. See [Queries → API responses](queries.md#api-responses-strip).
|
package/docs/queries.md
CHANGED
|
@@ -330,9 +330,7 @@ const users = await db.users.findMany({
|
|
|
330
330
|
// users[0].posts[0].title is string; .body is excluded from the type
|
|
331
331
|
```
|
|
332
332
|
|
|
333
|
-
### API responses (`strip`)
|
|
334
|
-
|
|
335
|
-
Use query `omit` when you do not want a column fetched from the database. Use `strip` when you need the full row internally (for example login) but want a safe object for the response.
|
|
333
|
+
### Sensitive columns (`.hidden()`) and API responses (`strip`)
|
|
336
334
|
|
|
337
335
|
Mark sensitive columns in the schema with `.hidden()`:
|
|
338
336
|
|
|
@@ -340,21 +338,38 @@ Mark sensitive columns in the schema with `.hidden()`:
|
|
|
340
338
|
password: text().notNull().hidden(),
|
|
341
339
|
```
|
|
342
340
|
|
|
343
|
-
|
|
341
|
+
By default, queries **omit** hidden columns from the result (root table and nested `with` includes). Pass `includeHidden: true` when the app needs them (for example password verification on login):
|
|
344
342
|
|
|
345
343
|
```ts
|
|
346
|
-
const user = await db.users.
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
344
|
+
const user = await db.users.findFirst({
|
|
345
|
+
where: { email: input.email },
|
|
346
|
+
includeHidden: true,
|
|
347
|
+
});
|
|
348
|
+
```
|
|
350
349
|
|
|
351
|
-
|
|
352
|
-
|
|
350
|
+
Nested includes follow the same rule:
|
|
351
|
+
|
|
352
|
+
```ts
|
|
353
|
+
const posts = await db.posts.findMany({
|
|
354
|
+
with: { author: true }, // author.password omitted
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
const posts = await db.posts.findMany({
|
|
358
|
+
with: { author: { includeHidden: true } },
|
|
359
|
+
});
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
You can still use `select` to fetch a subset that includes hidden columns. Use query `omit` to skip non-hidden columns you do not want fetched. Use `.strip()` when you fetched sensitive fields internally but want a safe object for the response:
|
|
363
|
+
|
|
364
|
+
```ts
|
|
365
|
+
const user = await db.users.findById(id, { includeHidden: true });
|
|
366
|
+
if (!user) return null;
|
|
367
|
+
return user.strip(); // plain object without password
|
|
353
368
|
|
|
354
369
|
return user.strip({ refreshToken: true }); // hidden + extra column keys
|
|
355
370
|
```
|
|
356
371
|
|
|
357
|
-
`strip()` returns a plain object (no `.strip` method) suitable for JSON responses.
|
|
372
|
+
Every row returned from queries includes a non-enumerable `.strip()` method. `strip()` recurses into nested `with` relations. It returns a plain object (no `.strip` method) suitable for JSON responses.
|
|
358
373
|
|
|
359
374
|
## Cursor pagination
|
|
360
375
|
|
package/docs/schema.md
CHANGED
|
@@ -51,7 +51,7 @@ Column field names use camelCase in TypeScript. By default SQL column names are
|
|
|
51
51
|
|
|
52
52
|
All column builders support `.notNull()`, `.unique()`, `.default(value)`, `.primary()`, `.map(name)`, `.hidden()`, `.index()`, and `.check("sql expression")`.
|
|
53
53
|
|
|
54
|
-
`.hidden()` marks a column as sensitive
|
|
54
|
+
`.hidden()` marks a column as sensitive. It is omitted from default query output on the root table and on nested `with` includes. Pass `includeHidden: true` when the app needs the value (for example password verification on login). Use `.strip()` to remove any remaining sensitive fields before JSON responses.
|
|
55
55
|
|
|
56
56
|
### Audit timestamps
|
|
57
57
|
|