on 04-30-2020 12:16 AM
I am trying to initialize my bookstore database with the defined domain model and sample data but I when I run npm run deploy, I get the error message shown in the first picture below. I will be grateful for any tips to complete this mission.
//Schemda.cds
namespace sap.capire.bookstore;
using { Currency, cuid, managed } from '@sap/cds/common';
using { sap.capire.products.Products } from '@sap/capire-products';
entity Books as projection on Products; extend Products with {
// Note: we map Books to Products to allow reusing AdminService as is
author : Association to Authors;
}
entity Authors : cuid {
firstname : String(111);
lastname : String(111);
books : Association to many Books on books.author = $self;
}
@Capabilities.Updatable: false
entity Orders : cuid, managed {
items : Composition of many OrderItems on items.parent = $self;
total : Decimal(9,2) @readonly;
currency : Currency;
}
@Capabilities.Updatable: false
entity OrderItems : cuid {
parent : Association to Orders not null;
book_ID : UUID;
amount : Integer;
netAmount : Decimal(9,2) @readonly;
}
//services.cds
using { sap.capire.bookstore as db } from '../db/schema';
// Define Books Service
service BooksService {
@readonly entity Books as projection on db.Books { *, category as genre } excluding { category, createdBy, createdAt, modifiedBy, modifiedAt };
@readonly entity Authors as projection on db.Authors;
}
// Define Orders Service
service OrdersService {
entity Orders as projection on db.Orders;
// OrderItems are auto exposed
}
// Reuse Admin Service
using { AdminService } from '@sap/capire-products';
extend service AdminService with {
entity Authors as projection on db.Authors;
}
//Jason package
{
"name": "bookstore",
"version": "1.0.0",
"description": "Generated by cds-services-archetype",
"license": "ISC",
"repository": "<Add your repository here>",
"scripts": {
"build": "cds build/all --clean",
"schema": "cds compile srv --to sql > srv/src/main/resources/schema.sql",
"deploy": "cds deploy"
},
"dependencies": {
"@sap/capire-products": "file:sap-capire-products-1.0.0.tgz",
"@sap/cds": "3.31.2"
},
"cds": {
"build": {
"target": "."
},
"requires": {
"db": {
"kind": "sqlite",
"model": [
"db",
"srv"
],
"credentials": {
"database": "sqlite.db"
}
}
},
"odata": {
"version": "v4"
}
},
"devDependencies": {
"sqlite3": "^4.2.0"
}
}
I would suggest you compare your project with the openSAP-week2-unit2 branch of cloud-cap-samples.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.