From dc072dd020101b47452ec154b4c53465a03e1bb9 Mon Sep 17 00:00:00 2001 From: Simon Zimmerman Date: Mon, 25 Nov 2024 21:40:59 +0000 Subject: [PATCH] refactor: add optional one to many relationship to model meta --- .../tanstack-query/tests/test-model-meta.ts | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/packages/plugins/tanstack-query/tests/test-model-meta.ts b/packages/plugins/tanstack-query/tests/test-model-meta.ts index 174abd1bd..1c59b956b 100644 --- a/packages/plugins/tanstack-query/tests/test-model-meta.ts +++ b/packages/plugins/tanstack-query/tests/test-model-meta.ts @@ -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'],