Hierarchy

Constructors

Methods

  • Parameters

    • entityID: string

    Returns Promise<number>

    Description

    Gets the total amount of data records stored in the entity.

    See

    https://help.tago.io/portal/en/kb/articles/entities Entities

    Example

    If receive an error "Authorization Denied", check policy Entity / Delete in Access Management.

    const result = await Resources.entities.amount("entity-id-123");
    console.log(result);
  • Parameters

    Returns Promise<{
        id: string;
    }>

    Description

    Creates a new entity in the account.

    See

    https://help.tago.io/portal/en/kb/articles/entities#Creating_an_Entity Creating an Entity

    Example

    If receive an error "Authorization Denied", check policy Entity / Create in Access Management.

    const result = await Resources.entities.create({
    name: "Temperature Sensors",
    schema: {
    temperature: { action: "create", type: "float", required: true } }
    });
    console.log(result); // { id: 'entity-id-123' }
  • Parameters

    • entityID: string
    • itemsToDelete: {
          ids: string[];
      }
      • ids: string[]

    Returns Promise<string>

    Description

    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.

    See

    https://help.tago.io/portal/en/kb/articles/entities#Managing_the_data_in_your_Entity Managing the data in your Entity

    Example

    const resources = new Resources({ token: "YOUR-PROFILE-TOKEN" });
    const result = await resources.entities.deleteEntityData("myEntityID", { ids: ["idOfTheRecord1"] });
    console.log(result); // 1 item(s) deleted
  • Parameters

    • entityID: string
    • field: string

    Returns Promise<{
        message: string;
    }>

    Description

    Removes a field from the entity schema.

    See

    https://help.tago.io/portal/en/kb/articles/entities#Managing_fields Managing Fields

    Example

    If receive an error "Authorization Denied", check policy Entity / Edit in Access Management.

    const result = await Resources.entities.deleteField("entity-id-123", "old_field");
    console.log(result); // { message: 'Entity Successfully Updated' }
  • Parameters

    Returns Promise<{
        message: string;
    }>

    Description

    Updates an existing entity's properties.

    See

    https://help.tago.io/portal/en/kb/articles/entities#Managing_fields Managing Fields

    Example

    If receive an error "Authorization Denied", check policy Entity / Edit in Access Management.

    const result = await Resources.entities.edit("entity-id-123", { name: "Updated Entity Name" });
    console.log(result); // { message: 'Entity Successfully Updated' }
  • Parameters

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

    Returns Promise<string>

    Description

    Updates existing data records in an entity.

    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.

    See

    https://help.tago.io/portal/en/kb/articles/entities#Managing_the_data_in_your_Entity Managing the data in your Entity

    Example

    const resources = new Resources({ token: "YOUR-PROFILE-TOKEN" });
    const result = await resources.entities.editEntityData("entity-id-123", {
    id: "record-id-123",
    temperature: 30.1
    });
    console.log(result); // 1 item(s) updated
  • Parameters

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

    Returns Promise<{
        message: string;
    }>

    Description

    Modifies the entity schema by adding new fields or managing indexes.

    See

    https://help.tago.io/portal/en/kb/articles/entities#Indexing_fields_to_improve_searching_and_sorting Indexing fields to improve searching and sorting

    Example

    If receive an error "Authorization Denied", check policy Entity / Edit in Access Management.

    const result = await Resources.entities.editSchemaIndex("entity-id-123", {
    schema: { unit: { action: "create", type: "float", required: false } },
    index: { temp_idx: { action: "create", fields: ["temperature"] } }
    });
    console.log(result); // { message: 'Entity Successfully Updated' }
  • Parameters

    • entityId: string

    Returns Promise<string>

    Description

    Removes all data records from an entity while preserving its structure and configuration.

    See

    https://help.tago.io/portal/en/kb/articles/entities#Managing_the_data_in_your_Entity Managing the data in your Entity

    Example

    If receive an error "Authorization Denied", check policy Entity / Delete in Access Management.

    const result = await Resources.entities.emptyEntityData("entity-id-123");
    console.log(result); // Data Successfully Removed
  • Parameters

    • entityID: string
    • Optional queryParams: EntityDataQuery
    • Optional options: {
          paramsSerializer?: any;
      }
      • Optional paramsSerializer?: any

    Returns Promise<EntityData[]>

    Description

    Retrieves data records stored in a specific entity with optional filtering parameters.

    See

    https://help.tago.io/portal/en/kb/articles/entities#Managing_the_data_in_your_Entity Managing the data in your Entity

    Example

    If receive an error "Authorization Denied", check policy Entity / Access in Access Management.

    const result = await Resources.entities.getEntityData("entity-id-123", { amount: 10, orderBy: "created_at,desc" });
    console.log(result); // [ { id: 'record-id-123', created_at: 2025-01-22T13:45:30.913Z, ... }, ... ]

    // Filtering by a specific field
    const result = await Resources.entities.getEntityData("entity-id-123", {
    filter: { temperature: "30" },
    index: "temp_idx",
    amount: 9999,
    });
    console.log(result); // [ { id: 'record-id-123', created_at: 2025-01-22T13:45:30.913Z, ... }, ... ]
  • Parameters

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

    Returns Promise<EntityListItem[]>

    Description

    Retrieves a paginated list of all entities from the account with filtering and sorting options.

    See

    https://help.tago.io/portal/en/kb/articles/entities Entities

    Example

    If receive an error "Authorization Denied", check policy Entity / Access in Access Management.

    const result = await Resources.entities.list({
    page: 1,
    fields: ["id", "name", "tags"],
    amount: 20
    });
    console.log(result); // [ { id: 'entity-id-123', name: 'test', tags: [] }, ... ]
  • Parameters

    • entityID: string
    • field: string
    • newName: string

    Returns Promise<{
        message: string;
    }>

    Description

    Renames a field in the entity schema.

    See

    https://help.tago.io/portal/en/kb/articles/entities#Managing_fields Managing Fields

    Example

    If receive an error "Authorization Denied", check policy Entity / Edit in Access Management.

    const result = await Resources.entities.renameField("entity-id-123", "old_name", "new_name");
    console.log(result); // { message: 'Entity Successfully Updated' }
  • Parameters

    Returns Promise<{
        message: string;
    }>

    Description

    Updates a field's configuration in the entity schema.

    See

    https://help.tago.io/portal/en/kb/articles/entities#Managing_fields Managing Fields

    Example

    If receive an error "Authorization Denied", check policy Entity / Edit in Access Management.

    const result = await Resources.entities.updateField("entity-id-123", "temperature", { required: false });
    console.log(result); // { message: 'Entity Successfully Updated' }