Hierarchy

Constructors

Methods

  • Get amount of data stored in the Device.

    Parameters

    • entityID: string

      Entity ID

    Returns Promise<number>

  • Generate a new entity for the account.

    Parameters

    Returns Promise<{
        id: string;
    }>

  • Deletes an entity from the account

    Parameters

    • entityID: string

      Entity ID

    Returns Promise<string>

  • Delete data records in a entity using the profile token and entity ID.

    See the example to understand how to use this method properly to have full control on what to delete.

    Parameters

    • entityID: string

      Entity ID.

    • itemsToDelete: {
          ids: string[];
      }

      Items to be deleted.

      • ids: string[]

    Returns Promise<string>

    Success message indicating amount of records deleted (can be 0).

    Example

    await Resources.entities.deleteEntityData("myEntityID", { ids: ["idOfTheRecord1", "idOfTheRecord2"] });
    
  • Delete a field from the entity schema

    Parameters

    • entityID: string

      entity ID

    • field: string

      field name to be deleted

    Returns Promise<string>

    Success message

  • Delete a index from the entity schema

    Parameters

    • entityID: string

      entity ID

    • index: string

      index name to be deleted

    Returns Promise<string>

    Success message

  • Modify any property of the entity

    Parameters

    • entityID: string

      Entity ID

    • entityObj: Partial<EntityCreateInfo>

      Entity object with fields to replace

    Returns Promise<string>

  • Edit data records in a entity using the profile token and entity ID.

    The updatedData can be a single data record or an array of records to be updated, each of the records must have the id of the record and the fields to be updated.

    Parameters

    • entityID: string

      Entity ID.

    • updatedData: {
          id: string;
      } & Partial<EntityData> | ({
          id: string;
      } & Partial<EntityData>)[]

      A single or an array of updated data records.

    Returns Promise<string>

    Success message indicating amount of records updated (can be 0).

    Example

    await Resources.devices.editEntityData("myEntityID", { id: "idOfTheRecord", field1: "new value", field2: "new unit" });
    
  • Add a field to the entity schema

    Parameters

    • entityID: string

      entity ID

    • data: {
          index?: Record<string, {
              action?: "create";
              fields?: string[];
          } | {
              action?: "delete";
          }>;
          schema?: EntitySchema;
      }

      schema or index to be added

      • Optional index?: Record<string, {
            action?: "create";
            fields?: string[];
        } | {
            action?: "delete";
        }>
      • Optional schema?: EntitySchema

    Returns Promise<string>

    Success message

  • Empty all data in a entity.

    Parameters

    • entityId: string

    Returns Promise<string>

    Success message

  • Get all the data from a entity.

    Parameters

    • entityID: string

      Entity ID

    • Optional queryParams: EntityDataQuery

      Query parameters to filter the results.

    • Optional options: {
          paramsSerializer?: any;
      }
      • Optional paramsSerializer?: any

    Returns Promise<EntityData[]>

    Array with the data values stored in the entity.

    Example

    const lastTenValues = await Resources.entities.getEntityData("myEntityID", { amount: 10 });
    
  • Retrieves a list with all entities from the account

    Parameters

    • Optional queryObj: EntityQuery

      Search query params

    • Optional options: {
          paramsSerializer?: any;
      }
      • Optional paramsSerializer?: any

    Returns Promise<EntityListItem[]>

    Default

    queryObj: {
    page: 1,
    fields: ["id", "name"],
    filter: {},
    amount: 20,
    orderBy: "name,asc",
    }
  • Rename a field from the entity schema

    Parameters

    • entityID: string

      entity ID

    • field: string

      field name to be renamed

    • newName: string

      new field name

    Returns Promise<string>

  • Send data records to a entity using the profile token and entity ID.

    The data can be a single data record or an array of records to be sent.

    Parameters

    Returns Promise<string>

    Success message indicating amount of records sent (can be 0).

  • Update a field from the entity schema

    Parameters

    • entityID: string

      entity ID

    • field: string

      field name to be updated

    • data: Partial<EntitySchema>

      data to be updated

    Returns Promise<string>