Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
1 REPLY 1

MattBrightman
Explorer
38

Given this schema:

entity Books {
  key ID           : UUID;
      title        : String;
      description  : String;
      stock        : Integer;
      reorderPoint : Integer;
      statusCode   : String;
      price        : Integer;
      to_Chapters  : Composition of many Chapters
                       on to_Chapters.to_Books = $self
}

entity Chapters {
  key ID       : UUID;
      title    : String;
      to_Books : Association to Books
}

Some code like:

const  payload = {
  title: "201",
  stock: 1,
  description: "capval 3",
  price: 3,
  statusCode: "A",
  reorderPoint: 6,
  to_Chapters: [
    {
      title: "Introduction",
    },
  ],
};

await cds.tx(req).run(INSERT.into(Books).entries(payload))