SAP-samples/cloud-cap-samples

Failed to insert mockup data

fourmatrix opened this issue · 1 comments

Refer to tutorial https://developers.sap.com/tutorials/cap-cloudsdk-1-mock-service.html,

I tried to mock hana service, but I change the location and content of server.js, I moved server.js to ./srv folder, and use 'served' event callback to insert mockup data, if failed with error:

[ERROR] SQLITE_ERROR: no such table: API_BUSINESS_PARTNER_A_BusinessPartnerAddressType

Snip20200903_14

the content of server.js is:

"use strict";

const cds = require("@sap/cds");
const proxy = require("@sap/cds-odata-v2-adapter-proxy");

cds.on("bootstrap", app => app.use(proxy()));

module.exports = cds.server;

cds.once("served", async (csn)=>{
  // Seed with sample data
  // cds.deploy('srv').to('sqlite::memory:',{primary:true}) .then (async db => {
    const db = await cds.connect.to("db"); //cds.db; //
    const { A_BusinessPartnerAddress: Addresses } = db.entities('API_BUSINESS_PARTNER')
    console.log('Adding sample data...')

    console.log(Addresses+'');

    const addresses = db.run (INSERT.into(Addresses+'').entries(
      {
        BusinessPartner: '1003764',
        AddressID: '28238',
        CityName: 'Walldorf',
        StreetName: 'Dietmar-Hopp-Allee'
      },
      {
        BusinessPartner: '1003765',
        AddressID: '28241',
        CityName: 'Palo Alto',
        StreetName: 'Hillview Avenue'
      },
      {
        BusinessPartner: '1003766',
        AddressID: '28244',
        CityName: 'Hallbergmoos',
        StreetName: 'Zeppelinstraße'
      },
      {
        BusinessPartner: '1003767',
        AddressID: '28247',
        CityName: 'Potsdam',
        StreetName: 'Konrad-Zuse-Ring'
      }
    ))

    await Promise.all ([addresses])

    console.log('Adding sample data... success')
  // }) .catch (console.error)

})
chgeo commented

Hey.. thanks for reporting. We want to close down this issue channel, so please report the question over on the community.
Thanks.