TagoIO SDK for JavaScript and TypeScript
    Preparing search index...

    Class Entities

    Hierarchy

    Index

    Constructors

    Methods

    • Parameters

      • entityID: string

      Returns Promise<number>

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

      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

      • entityID: string

      Returns Promise<string>

      Permanently removes an entity from the account.

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

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

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

      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.

      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 }>

      Removes a field from the entity schema.

      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

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

      Returns Promise<string>

      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.

      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;
        }

      Returns Promise<{ message: string }>

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

      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>

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

      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
      • OptionalqueryParams: EntityDataQuery
      • Optionaloptions: { paramsSerializer?: any }

      Returns Promise<EntityData[]>

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

      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

      • entityID: string

      Returns Promise<EntityInfo>

      Retrieves detailed information about a specific entity.

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

      const result = await Resources.entities.info("entity-id-123");
      console.log(result); // { schema: { id: { type: 'uuid', required: true }, ... }, ... }
    • Parameters

      • OptionalqueryObj: EntityQuery
      • Optionaloptions: { paramsSerializer?: any }

      Returns Promise<EntityListItem[]>

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

      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 }>

      Renames a field in the entity schema.

      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 }>

      Updates a field's configuration in the entity schema.

      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' }