Options
All
  • Public
  • Public/Protected
  • All
Menu

Module business-objects

@dvelop-sdk/business-objects

npm (scoped) npm bundle size (scoped) GitHub license

This package contains functionality for the BusinessObjects-App in the d.velop cloud.

Explore the docs »
Install via npm »
Check us out on GitHub »

Index

Functions

  • Create a business object entity.

    example
    import { createBoEntity } from "@dvelop-sdk/business-objects";

    await createBoEntity({
    systemBaseUri: "https://sacred-heart-hospital.d-velop.cloud",
    authSessionId: "3f3c428d452"
    },{
    modelName: "HOSPITALBASEDATA",
    pluralEntityName: "employees",
    entity: {
    employeeId: "1",
    firstName: "John Micheal",
    lastName: "Dorian",
    jobTitel: "senior physician"
    }
    });

    You can also use generics:

    example
    import { createBoEntity } from "@dvelop-sdk/business-objects";

    interface Employee {
    employeeId: string;
    firstName: string;
    lastName: string;
    jobTitel: string;
    }

    await create<Employee>({
    systemBaseUri: "https://sacred-heart-hospital.d-velop.cloud",
    authSessionId: "3f3c428d452"
    },{
    modelName: "HOSPITALBASEDATA",
    pluralEntityName: "employees",
    entity: {
    employeeId: "1",
    firstName: "John Micheal",
    lastName: "Dorian",
    jobTitel: "senior physician"
    }
    });

    Type Parameters

    • E = any

      Type for Entity. Defaults to any.

    Parameters

    Returns Promise<void>

  • Delete a business object entity.

    example
    import { deleteBoEntity } from "@dvelop-sdk/business-objects";

    await deleteBoEntity({
    systemBaseUri: "https://sacred-heart-hospital.d-velop.cloud",
    authSessionId: "3f3c428d452"
    },{
    modelName: "HOSPITALBASEDATA",
    pluralEntityName: "employees",
    keyPropertyType: "number", //"string", "number" or "guid"
    keyPropertyValue: 1
    });

    You can also write your own function, for example to get a notification, if the entity requested for deletion doesn't exist.

    example
    import { deleteBoEntity } from "@dvelop-sdk/business-objects";

    const myDeleteFunction = _deleteBoEntityFactory(_defaultHttpRequestFunction, (response: HttpResponse) => {
    if(response.status === 204) {
    return "Entity does not exist.";
    } else {
    return "Entity was deleted.";
    }
    });

    const responseMessage: string = await myDeleteFunction({
    systemBaseUri: "https://sacred-heart-hospital.d-velop.cloud",
    authSessionId: "3f3c428d452"
    },{
    modelName: "HOSPITALBASEDATA",
    pluralEntityName: "employees",
    keyPropertyType: "number", //"string", "number" or "guid"
    keyPropertyValue: 3
    });

    console.log(responseMessage); // Entity does not exist.

    Parameters

    Returns Promise<void>

  • Returns all specified entities from a model. This result might be partial due to the default page size. You can navigate to the next pages using the function getNextPage. If the function is undefined, the page does not exist.

    example
    import { getBoEntities } from "@dvelop-sdk/business-objects";

    const resultPage: GetEntitiesResultPage = await getBoEntities({
    systemBaseUri: "https://sacred-heart-hospital.d-velop.cloud",
    authSessionId: "3f3c428d452"
    },{
    modelName: "HOSPITALBASEDATA",
    pluralEntityName: "employees"
    });

    let employees = await resultPage.value;

    // Use this for paging
    while (resultPage.getNextPage) {
    const nextPage: GetBoEntitiesResultPage = await resultPage.getNextPage();
    employees = employees.concat(nextPage.value);
    }

    You can also use generics:

    • @example
    import { getBoEntities } from "@dvelop-sdk/business-objects";

    interface Employee {
    employeeId: string;
    firstName: string;
    lastName: string;
    jobTitel: string;
    }

    const resultPage: GetBoEntitiesResultPage<Employee> = await getBoEntities({
    systemBaseUri: "https://sacred-heart-hospital.d-velop.cloud",
    authSessionId: "3f3c428d452"
    }, {
    modelName: "HOSPITALBASEDATA",
    pluralEntityName: "employees"
    });

    let employees: Employee[] = await resultPage.value;

    // Use this for paging
    while (resultPage.getNextPage) {
    const nextPage: GetBoEntitiesResultPage<Employee> = await resultPage.getNextPage();
    employees = employees.concat(nextPage.value);
    }

    employees.forEach(e => console.log(e.lastName));
    // Dorian
    // Turk

    Type Parameters

    • E = any

    Parameters

    Returns Promise<GetBoEntitiesResultPage<E>>

  • Returns one specified entity from a model.

    example
    import { getBoEntity } from "@dvelop-sdk/business-objects";

    const jd = await getBoEntity({
    systemBaseUri: "https://sacred-heart-hospital.d-velop.cloud",
    authSessionId: "3f3c428d452"
    },{
    modelName: "HOSPITALBASEDATA",
    pluralEntityName: "employees",
    keyPropertyType: "string", //"string", "number" or "guid"
    keyPropertyValue: "1"
    });
    console.log(jd); // { employeeId: '1', firstName: 'John Micheal', lastName: 'Dorian', jobTitel: 'senior physician' }

    You can also use generics:

    example
    import { getBoEntity } from "@dvelop-sdk/business-objects";

    interface Employee {
    employeeId: string;
    firstName: string;
    lastName: string;
    jobTitel: string;
    }

    const jd: Employee = await getBoEntity<Employee>({
    systemBaseUri: "https://sacred-heart-hospital.d-velop.cloud",
    authSessionId: "3f3c428d452"
    },{
    modelName: "HOSPITALBASEDATA",
    pluralEntityName: "employees",
    keyPropertyType: "string", //"string", "number" or "guid"
    keyPropertyValue: "1"
    });

    console.log(jd.lastName); // Dorian

    Type Parameters

    • E = any

      Type for Entity. Defaults to any.

    Parameters

    Returns Promise<E>

  • Update a business object entity.

    example
    import { updateBoEntity } from "@dvelop-sdk/business-objects";

    await updateBoEntity({
    systemBaseUri: "https://sacred-heart-hospital.d-velop.cloud",
    authSessionId: "3f3c428d452"
    },{
    modelName: "HOSPITALBASEDATA",
    pluralEntityName: "employees",
    keyPropertyType: "number", //"string", "number" or "guid"
    keyPropertyValue: 1,
    entityChange: {
    "firstName": "J.D."
    }
    });

    You can also use generics:

    example
    import { updateBoEntity } from "@dvelop-sdk/business-objects";

    interface Employee {
    employeeId: string;
    firstName: string;
    lastName: string;
    jobTitel: string;
    }

    await updateBoEntity<Employee>({
    systemBaseUri: "https://sacred-heart-hospital.d-velop.cloud",
    authSessionId: "3f3c428d452"
    },{
    modelName: "HOSPITALBASEDATA",
    pluralEntityName: "employees",
    keyPropertyType: "number", //"string", "number" or "guid"
    keyPropertyValue: 1,
    entityChange: {
    "firstName": "John Micheal (J.D.)"
    }
    });

    Type Parameters

    • E = any

      Type for Entity. Defaults to any.

    Parameters

    Returns Promise<void>

Generated using TypeDoc