@metaobjectsdev/sdk 0.15.0-rc.1 → 0.15.1-rc.1
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.
|
@@ -384,7 +384,7 @@ The `[]` key-suffix declares an array field: `field.long[]: weekIds` lowers to
|
|
|
384
384
|
| Subtype | Purpose | Key attrs |
|
|
385
385
|
|---|---|---|
|
|
386
386
|
| `identity.primary` | the PK field(s) | `@fields`, `@generation` |
|
|
387
|
-
| `identity.secondary` | a unique
|
|
387
|
+
| `identity.secondary` | a unique alternate key (always enforces uniqueness — uniqueness is the type, not a `@unique` attr) | `@fields` (or `@expr` for a functional index) |
|
|
388
388
|
| `identity.reference` | an inbound FK from this entity to another | `@fields`, `@references`, `@enforce` |
|
|
389
389
|
|
|
390
390
|
`@generation` on a primary controls value generation (e.g. `increment`).
|
|
@@ -407,7 +407,7 @@ PK needs the explicit dotted form `@references: "pkg::Target.fieldA,fieldB"`.
|
|
|
407
407
|
exist (previously such references loaded silently). So every `@references` /
|
|
408
408
|
`@objectRef` you author must name a real entity.
|
|
409
409
|
|
|
410
|
-
|
|
410
|
+
An `identity.secondary` can index an **expression** instead of plain columns: use
|
|
411
411
|
`@expr` (e.g. `"lower(email)"`) in place of `@fields`, optionally with `@using` (the
|
|
412
412
|
index method — `gin` / `gist` / `hash`; default `btree`) and `@where` (a partial-index
|
|
413
413
|
predicate).
|
|
@@ -419,6 +419,30 @@ predicate).
|
|
|
419
419
|
{ "identity.reference": { "name": "fkAuthor", "@fields": ["authorId"], "@references": "Author", "@enforce": true } }
|
|
420
420
|
```
|
|
421
421
|
|
|
422
|
+
## Indexes (non-unique)
|
|
423
|
+
|
|
424
|
+
Use `index.lookup` for a **non-unique** DB index added purely for query performance — it
|
|
425
|
+
does NOT enforce uniqueness. Choose the right construct by what the constraint IS:
|
|
426
|
+
|
|
427
|
+
| Need | Construct |
|
|
428
|
+
|---|---|
|
|
429
|
+
| Unique alternate key (e.g. email, slug) | `identity.secondary` — uniqueness is the type |
|
|
430
|
+
| Query-performance index, no uniqueness | `index.lookup` |
|
|
431
|
+
|
|
432
|
+
`@fields` names the indexed columns and is **required** (at least one). The db provider
|
|
433
|
+
contributes physical-tuning attrs: `@orders` (per-column sort direction), `@using` (access
|
|
434
|
+
method — `gin`/`gist`/`hash`; default `btree`), `@expr` (key expression derived from
|
|
435
|
+
`@fields`, e.g. for a functional index), and `@where` (partial-index predicate).
|
|
436
|
+
|
|
437
|
+
```json
|
|
438
|
+
{ "index.lookup": { "name": "byCreatedAt", "@fields": ["createdAt"], "@orders": ["desc"] } }
|
|
439
|
+
{ "index.lookup": { "name": "byStatusCreatedAt", "@fields": ["status", "createdAt"] } }
|
|
440
|
+
{ "index.lookup": { "name": "byEmailCI", "@fields": ["email"], "@expr": "lower(email)" } }
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
`index.lookup` is a sibling of `identity.*` — declare it as a direct child of an `object.entity`,
|
|
444
|
+
at the same level as fields and identities.
|
|
445
|
+
|
|
422
446
|
## Relationships
|
|
423
447
|
|
|
424
448
|
`relationship.composition` is the "this entity owns / aggregates instances of
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metaobjectsdev/sdk",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.1-rc.1",
|
|
4
4
|
"description": "Workspace helpers and agent-docs utilities for MetaObjects projects.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@metaobjectsdev/metadata": "0.15.
|
|
59
|
+
"@metaobjectsdev/metadata": "0.15.1-rc.1",
|
|
60
60
|
"zod": "^3.23.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|