zenstack/packages/plugins/tanstack-query/tests/test-model-meta.ts
Yiming 420df87bf1
merge v2 to dev (#1281)
Co-authored-by: Augustin <43639468+Azzerty23@users.noreply.github.com>
Co-authored-by: Jonathan Stevens <jonathan.stevens@resnovas.com>
Co-authored-by: Jonathan S <jonathan.stevens@eventiva.co.uk>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: ErikMCM <70036542+ErikMCM@users.noreply.github.com>
Co-authored-by: Jason Kleinberg <ustice@gmail.com>
Co-authored-by: Jonathan S <punk.gift9475@alias.org.uk>
Co-authored-by: Jiasheng <jiashengguo@outlook.com>
2024-04-24 21:19:41 +08:00

57 lines
1.8 KiB
TypeScript

import { ModelMeta } from '@zenstackhq/runtime/cross';
const fieldDefaults = {
isId: false,
isDataModel: false,
isArray: false,
isOptional: true,
attributes: [],
isRelationOwner: false,
isForeignKey: false,
};
export const modelMeta: ModelMeta = {
models: {
user: {
name: 'user',
fields: {
id: {
...fieldDefaults,
type: 'String',
isId: true,
name: 'id',
isOptional: false,
},
name: { ...fieldDefaults, type: 'String', name: 'name' },
email: { ...fieldDefaults, type: 'String', name: 'name', isOptional: false },
posts: {
...fieldDefaults,
type: 'Post',
isDataModel: true,
isArray: true,
name: 'posts',
},
},
uniqueConstraints: { id: { name: 'id', fields: ['id'] } },
},
post: {
name: 'post',
fields: {
id: {
...fieldDefaults,
type: 'String',
isId: true,
name: 'id',
isOptional: false,
},
title: { ...fieldDefaults, type: 'String', name: 'title' },
owner: { ...fieldDefaults, type: 'User', name: 'owner', isDataModel: true, isRelationOwner: true },
ownerId: { ...fieldDefaults, type: 'User', name: 'owner', isForeignKey: true },
},
uniqueConstraints: { id: { name: 'id', fields: ['id'] } },
},
},
deleteCascade: {
user: ['Post'],
},
};