use database constraints

... in bookshop, orders, reviews
+ update package.json and package-lock.json as db constraints
  requires latest cds
This commit is contained in:
Steffen Weinstock
2021-12-20 17:20:36 +01:00
parent 379ddc9fb0
commit a524e419db
6 changed files with 1621 additions and 1782 deletions

View File

@@ -18,6 +18,9 @@
"db": {
"kind": "sql"
}
},
"features": {
"assert_integrity": "db"
}
}
}

View File

@@ -17,7 +17,7 @@ GET {{server}}/browse/$metadata
### ------------------------------------------------------------------------
# Browse Books as any user
GET {{server}}/browse/Books?
# &$select=title,stock
&$select=title,stock,author
# &$expand=currency
# &sap-language=de
{{me}}
@@ -62,6 +62,22 @@ Authorization: Basic alice:
"currency": { "code": "USD" }
}
### ------------------------------------------------------------------------
# Create book with invalid author ID -> will fail
POST {{server}}/admin/Books
Content-Type: application/json;IEEE754Compatible=true
Authorization: Basic alice:
{
"ID": 34,
"title": "Let constraints do the magic",
"descr": "Database constraints are helpful little things that prevent messing up your data.",
"author": { "ID": 777 },
"genre": { "ID": 14 },
"stock": 4,
"price": "19.99",
"currency": { "code": "USD" }
}
### ------------------------------------------------------------------------
# Put image to books

View File

@@ -4,5 +4,10 @@
"dependencies": {
"@capire/common": "*",
"@sap/cds": "^5"
},
"cds": {
"features": {
"assert_integrity": "db"
}
}
}

3372
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -13,7 +13,7 @@
"@capire/media": "./media",
"@capire/orders": "./orders",
"@capire/reviews": "./reviews",
"@sap/cds": "^5.5.3"
"@sap/cds": "^5.7.3"
},
"devDependencies": {
"chai": "^4.3.4",

View File

@@ -18,6 +18,9 @@
"[production]": { "kind": "enterprise-messaging" }
},
"db": { "kind": "sql" }
},
"features": {
"assert_integrity": "db"
}
}
}