Skip to content

Commit

Permalink
refactor: add optional one to many relationship to model meta
Browse files Browse the repository at this point in the history
  • Loading branch information
roomman committed Nov 25, 2024
1 parent b7c6c87 commit dc072dd
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions packages/plugins/tanstack-query/tests/test-model-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,46 @@ export const modelMeta: ModelMeta = {
foreignKeyMapping: { id: 'ownerId' },
},
ownerId: { ...fieldDefaults, type: 'String', name: 'ownerId', isForeignKey: true },
category: {
...fieldDefaults,
type: 'Category',
name: 'category',
isDataModel: true,
isOptional: true,
isRelationOwner: true,
backLink: 'posts',
foreignKeyMapping: { id: 'categoryId' },
},
categoryId: {
...fieldDefaults,
type: 'String',
name: 'categoryId',
isForeignKey: true,
relationField: 'category',
},
},
uniqueConstraints: { id: { name: 'id', fields: ['id'] } },
},
category: {
name: 'category',
fields: {
id: {
...fieldDefaults,
type: 'String',
isId: true,
name: 'id',
isOptional: false,
},
name: { ...fieldDefaults, type: 'String', name: 'name' },
posts: {
...fieldDefaults,
type: 'Post',
isDataModel: true,
isArray: true,
name: 'posts',
},
},
},
},
deleteCascade: {
user: ['Post'],
Expand Down

0 comments on commit dc072dd

Please sign in to comment.