Skip to content

Commit 8cbea94

Browse files
CopilotCopilot
andcommitted
refactor: replace standalone _id with id across protocol files, tests, and docs
Replace MongoDB-style _id field references with the platform-standard id field name in: - Mock kernels (studio, client tests) - REST, runtime, and objectql test data - QA testing schema and tests - Documentation examples and SQL snippets Compound identifiers (owner_id, account_id, tenant_id) are preserved. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent fba7127 commit 8cbea94

20 files changed

Lines changed: 46 additions & 46 deletions

File tree

apps/studio/src/mocks/createKernel.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export async function createKernel(options: KernelOptions) {
6565
if (method === 'create') {
6666
const res = await ql.insert(params.object, params.data);
6767
const record = { ...params.data, ...res };
68-
return { object: params.object, id: record.id || record._id, record };
68+
return { object: params.object, id: record.id, record };
6969
}
7070
if (method === 'get') {
7171
// Delegate to protocol for proper expand/select support
@@ -74,7 +74,7 @@ export async function createKernel(options: KernelOptions) {
7474
}
7575
let all = await ql.find(params.object);
7676
if (!all) all = [];
77-
const match = all.find((i: any) => i.id === params.id || i._id === params.id);
77+
const match = all.find((i: any) => i.id === params.id);
7878
return match ? { object: params.object, id: params.id, record: match } : null;
7979
}
8080
if (method === 'update') {
@@ -85,7 +85,7 @@ export async function createKernel(options: KernelOptions) {
8585
if (all && (all as any).value) all = (all as any).value;
8686
if (!all) all = [];
8787

88-
const existing = all.find((i: any) => i.id === params.id || i._id === params.id);
88+
const existing = all.find((i: any) => i.id === params.id);
8989

9090
if (!existing) {
9191
console.warn(`[BrokerShim] Update failed: Record ${params.id} not found.`);
@@ -183,7 +183,7 @@ export async function createKernel(options: KernelOptions) {
183183
: String(queryOptions.select).split(',').map((s: string) => s.trim());
184184

185185
all = all.map((item: any) => {
186-
const projected: any = { id: item.id, _id: item._id }; // Always include ID
186+
const projected: any = { id: item.id }; // Always include ID
187187
selectFields.forEach((f: string) => {
188188
if (item[f] !== undefined) projected[f] = item[f];
189189
});

content/docs/guides/standards.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ describe('Account Object', () => {
545545
- [ ] All objects use `ObjectSchema.create()`
546546
- [ ] Field names are `snake_case`
547547
- [ ] Config keys are `camelCase`
548-
- [ ] Lookups don't have `_id` suffix
548+
- [ ] Lookups don't have `_id` suffix (use `id`)
549549
- [ ] All validations have clear messages
550550
- [ ] Documentation is up to date
551551
- [ ] Tests pass

content/docs/protocol/objectql/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const query: Query = {
147147
-- PostgreSQL (with JOIN)
148148
SELECT c.company_name, c.industry, u.name AS "owner.name"
149149
FROM customer c
150-
LEFT JOIN user u ON c.owner_id = u._id
150+
LEFT JOIN user u ON c.owner_id = u.id
151151
WHERE c.industry = 'tech' AND c.annual_revenue > 1000000
152152
ORDER BY c.created_at DESC
153153
LIMIT 10;

content/docs/protocol/objectql/query-syntax.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ SELECT
407407
o.amount,
408408
a.company_name AS "account.company_name"
409409
FROM opportunity o
410-
LEFT JOIN account a ON o.account_id = a._id
410+
LEFT JOIN account a ON o.account_id = a.id
411411
```
412412

413413
### Multiple Relationships
@@ -594,7 +594,7 @@ const query = {
594594
['exists', {
595595
object: 'opportunity',
596596
filters: [
597-
['account_id', '=', '{{parent._id}}'],
597+
['account_id', '=', '{{parent.id}}'],
598598
['stage', '=', 'Closed Won']
599599
]
600600
}]
@@ -603,7 +603,7 @@ const query = {
603603

604604
// SQL: WHERE EXISTS (
605605
// SELECT 1 FROM opportunity
606-
// WHERE opportunity.account_id = account._id
606+
// WHERE opportunity.account_id = account.id
607607
// AND opportunity.stage = 'Closed Won'
608608
// )
609609
```
@@ -617,7 +617,7 @@ const query = {
617617
['not_exists', {
618618
object: 'opportunity',
619619
filters: [
620-
['account_id', '=', '{{parent._id}}']
620+
['account_id', '=', '{{parent.id}}']
621621
]
622622
}]
623623
]
@@ -778,17 +778,17 @@ const page2 = await ObjectQL.query({
778778
const result = await ObjectQL.query({
779779
object: 'customer',
780780
limit: 10,
781-
sort: [{ field: '_id', order: 'asc' }]
781+
sort: [{ field: 'id', order: 'asc' }]
782782
});
783783

784-
// Next page (use last _id as cursor)
784+
// Next page (use last id as cursor)
785785
const nextResult = await ObjectQL.query({
786786
object: 'customer',
787787
filters: [
788-
['_id', '>', result[result.length - 1]._id]
788+
['id', '>', result[result.length - 1].id]
789789
],
790790
limit: 10,
791-
sort: [{ field: '_id', order: 'asc' }]
791+
sort: [{ field: 'id', order: 'asc' }]
792792
});
793793
```
794794

@@ -808,7 +808,7 @@ const customer = await ObjectQL.findOne('customer', '123');
808808
// Equivalent to:
809809
await ObjectQL.query({
810810
object: 'customer',
811-
filters: [['_id', '=', '123']],
811+
filters: [['id', '=', '123']],
812812
limit: 1
813813
});
814814
```

content/docs/protocol/objectql/schema.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ label: Project
7575
```
7676
7777
This 2-line definition creates:
78-
- Database table `project` with system fields (`_id`, `created_at`, `updated_at`)
78+
- Database table `project` with system fields (`id`, `created_at`, `updated_at`)
7979
- REST API: `GET/POST/PUT/DELETE /api/project`
8080
- Admin UI: List view + Form
8181
- TypeScript types

content/docs/protocol/objectql/types.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ account_id:
533533
deleteBehavior: set_null # or restrict, cascade
534534
```
535535

536-
**Storage:** Stores `_id` of referenced record
536+
**Storage:** Stores `id` of referenced record
537537

538538
**Query behavior:**
539539
```typescript
@@ -617,7 +617,7 @@ parent:
617617
**Storage:**
618618
```json
619619
{
620-
"_id": "123",
620+
"id": "123",
621621
"_type": "account"
622622
}
623623
```

content/docs/protocol/objectui/layout-dsl.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ sections:
522522
- type: related_list
523523
label: Contacts
524524
object: contact
525-
relationField: account_id # contact.account_id → account._id
525+
relationField: account_id # contact.account_id → account.id
526526
columns:
527527
- name
528528
- email

content/docs/references/qa/testing.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ A single step in a test scenario, consisting of an action and optional assertion
126126
| **description** | `string` | optional | Human-readable description of what this step tests |
127127
| **action** | `Object` || The action to execute in this step |
128128
| **assertions** | `Object[]` | optional | Assertions to validate after the action completes |
129-
| **capture** | `Record<string, string>` | optional | Map result fields to context variables: `{ "newId": "body._id" }` |
129+
| **capture** | `Record<string, string>` | optional | Map result fields to context variables: `{ "newId": "body.id" }` |
130130

131131

132132
---

content/prompts/platform/automation.prompt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export const LeadQualifyFlow: FlowSchema = {
8585
label: 'Get Lead Details',
8686
config: {
8787
object: 'lead',
88-
filter: [['_id', '=', '{leadId}']]
88+
filter: [['id', '=', '{leadId}']]
8989
}
9090
},
9191
{

content/prompts/plugin/data-seed.prompt.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export async function seedRoles() {
4646
await object.insert(role);
4747
console.log(`Created Role: ${role.name}`);
4848
} else {
49-
await object.update(existing._id, role);
49+
await object.update(existing.id, role);
5050
console.log(`Updated Role: ${role.name}`);
5151
}
5252
}
@@ -103,7 +103,7 @@ export const SplitNamesJob: JobSchema = {
103103
for (const c of contacts) {
104104
const [first, ...rest] = c.full_name.split(' ');
105105
await ctx.broker.call('contact.update', {
106-
id: c._id,
106+
id: c.id,
107107
data: { first_name: first, last_name: rest.join(' ') }
108108
});
109109
}

0 commit comments

Comments
 (0)