From 19b680ab3d4f457d7a624ba1563a50a5c783a486 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 24 Nov 2021 19:30:47 +0100 Subject: [PATCH] Moving lifetime + age to where it is used Signed-off-by: Daniel --- bookstore/db/schema.cds | 8 -------- bookstore/index.cds | 4 +--- bookstore/package.json | 8 +------- {bookstore => fiori}/db/hana/index.cds | 2 +- {bookstore => fiori}/db/sqlite/index.cds | 2 +- fiori/package.json | 9 +++++++++ 6 files changed, 13 insertions(+), 20 deletions(-) delete mode 100644 bookstore/db/schema.cds rename {bookstore => fiori}/db/hana/index.cds (84%) rename {bookstore => fiori}/db/sqlite/index.cds (86%) diff --git a/bookstore/db/schema.cds b/bookstore/db/schema.cds deleted file mode 100644 index 479fdbfb..00000000 --- a/bookstore/db/schema.cds +++ /dev/null @@ -1,8 +0,0 @@ -using { sap.capire.bookshop } from '@capire/bookshop'; - -// Forward-declare calculated fields to be filled in database-specific ways -// TODO find a better way to have 'default' fields that still can be overwritten. -extend bookshop.Authors with { - virtual age: Integer; - virtual lifetime: String; -} diff --git a/bookstore/index.cds b/bookstore/index.cds index 4b86c023..ac2accff 100644 --- a/bookstore/index.cds +++ b/bookstore/index.cds @@ -1,4 +1,2 @@ namespace sap.capire.bookshop; //> important for reflection - -using from '@capire/bookshop'; -using from './db/schema'; +using from './srv/mashup'; diff --git a/bookstore/package.json b/bookstore/package.json index 216156e6..f69dae7a 100644 --- a/bookstore/package.json +++ b/bookstore/package.json @@ -25,13 +25,7 @@ "[production]": { "kind": "enterprise-messaging" } }, "db": { - "kind": "sql", - "[development]": { - "model": "db/sqlite" - }, - "[production]": { - "model": "db/hana" - } + "kind": "sql" } }, "log": { "service": true } diff --git a/bookstore/db/hana/index.cds b/fiori/db/hana/index.cds similarity index 84% rename from bookstore/db/hana/index.cds rename to fiori/db/hana/index.cds index 04822ad0..866e8741 100644 --- a/bookstore/db/hana/index.cds +++ b/fiori/db/hana/index.cds @@ -2,7 +2,7 @@ // Add Author.age and .lifetime with a DB-specific function // -using { AdminService } from '../schema'; +using { AdminService } from '@capire/bookshop'; extend projection AdminService.Authors with { YEARS_BETWEEN(dateOfBirth, dateOfDeath) as age: Integer, diff --git a/bookstore/db/sqlite/index.cds b/fiori/db/sqlite/index.cds similarity index 86% rename from bookstore/db/sqlite/index.cds rename to fiori/db/sqlite/index.cds index 019335ef..7bdfc6bb 100644 --- a/bookstore/db/sqlite/index.cds +++ b/fiori/db/sqlite/index.cds @@ -2,7 +2,7 @@ // Add Author.age and .lifetime with a DB-specific function // -using { AdminService } from '../schema'; +using { AdminService } from '@capire/bookshop'; extend projection AdminService.Authors with { strftime('%Y',dateOfDeath)-strftime('%Y',dateOfBirth) as age: Integer, diff --git a/fiori/package.json b/fiori/package.json index cf2f5ce1..64528079 100644 --- a/fiori/package.json +++ b/fiori/package.json @@ -29,6 +29,15 @@ "[development]": { "kind": "file-based-messaging" }, "[hybrid!]": { "kind": "enterprise-messaging-shared" } }, + "db": { + "kind": "sql", + "[development]": { + "model": "db/sqlite" + }, + "[production]": { + "model": "db/hana" + } + }, "hana": { "deploy-format": "hdbtable" }