Skip to content

Commit 673771c

Browse files
Copilothotlong
andcommitted
docs: update plugin-spec and i18n-standard with ObjectSchema.create()
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 3524330 commit 673771c

2 files changed

Lines changed: 26 additions & 35 deletions

File tree

content/docs/objectos/i18n-standard.mdx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -517,21 +517,23 @@ ObjectQL objects and fields can be **automatically translated**:
517517

518518
```typescript
519519
// Object definition
520-
export default defineObject({
520+
import { ObjectSchema, Field } from '@objectstack/spec/data';
521+
522+
export const Account = ObjectSchema.create({
521523
name: 'account',
522524
label: 'account.label', // Translation key
523525
pluralLabel: 'account.pluralLabel',
526+
icon: 'building',
524527

525528
fields: {
526-
name: {
527-
type: 'text',
529+
name: Field.text({
528530
label: 'account.fields.name', // Translation key
529-
},
530-
industry: {
531-
type: 'select',
531+
}),
532+
533+
industry: Field.select({
532534
label: 'account.fields.industry',
533-
options: 'account.industries', // Translation key for array
534-
},
535+
options: 'account.industries', // Translation key for options array
536+
}),
535537
},
536538
});
537539
```

content/docs/objectos/plugin-spec.mdx

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -231,54 +231,43 @@ Define database objects using ObjectQL schema syntax:
231231

232232
```typescript
233233
// src/objects/account.object.ts
234-
import { defineObject } from '@objectstack/core';
234+
import { ObjectSchema, Field } from '@objectstack/spec/data';
235235

236-
export default defineObject({
236+
export const Account = ObjectSchema.create({
237237
name: 'account',
238238
label: 'Account',
239239
pluralLabel: 'Accounts',
240+
icon: 'building',
240241

241242
fields: {
242-
name: {
243-
type: 'text',
243+
name: Field.text({
244244
label: 'Account Name',
245245
required: true,
246246
maxLength: 255,
247-
},
247+
}),
248248

249-
industry: {
250-
type: 'select',
249+
industry: Field.select({
251250
label: 'Industry',
252251
options: [
253-
{ value: 'technology', label: 'Technology' },
254-
{ value: 'finance', label: 'Finance' },
255-
{ value: 'healthcare', label: 'Healthcare' },
252+
{ label: 'Technology', value: 'technology' },
253+
{ label: 'Finance', value: 'finance' },
254+
{ label: 'Healthcare', value: 'healthcare' },
256255
],
257-
},
256+
}),
258257

259-
annual_revenue: {
260-
type: 'currency',
258+
annual_revenue: Field.currency({
261259
label: 'Annual Revenue',
262-
precision: 2,
263-
},
260+
scale: 2,
261+
}),
264262

265-
primary_contact: {
266-
type: 'lookup',
263+
primary_contact: Field.lookup('contact', {
267264
label: 'Primary Contact',
268-
reference: 'contact',
269-
},
270-
271-
opportunities: {
272-
type: 'reverse_lookup',
273-
label: 'Opportunities',
274-
reference: 'opportunity',
275-
referenceField: 'account',
276-
},
265+
}),
277266
},
278267

279268
enable: {
280269
trackHistory: true,
281-
search: true,
270+
searchable: true,
282271
apiEnabled: true,
283272
},
284273
});

0 commit comments

Comments
 (0)