Data Query vs Bucket records

Hi, I try to understand this:
When I run this data query I get #X records

const device = new Device({ token: “my-device-token” });
const [records] = await device.getData({ variables: [“digital”],
query: “count”
context.log(Records count: ,records.value);

When I look in the bucket of that device (see attached), and filter by that variable, I get a totally different number of registers for each device.
So I clearly do not understand the relation between my query, the # records for that variable returned and number of registers in the bucket for the same variable. I would expect the same numbers. The query returns much higher numbers.

Can someone explain?

From my tests here, the count is working as expected, and it must reflect the number of register you see in the bucket.

What I found weird is that you have two digital variables in the screenshot you posted. Can you get those using the API and see what is the difference between them?

1 Like

Hi @vincent.raaijmakers ,

getData query for all variables linked to the device’s bucket. Meaning you should be receiving the count of all variables named “digital”.


1 Like

In this case, you may want to filter by origin:

device.getData({ variables: [“digital”], origins: [“your-device-id”], query: “count” })


Gotcha! In my assumption, device.getData is a call the get the data for that device only.
A bit confusing. Ok, let me do some more testing on my end.

Appreciate all the help!!


1 Like

Correct, I have 2 same type of devices (door sensors). Different ID’s of course but they share the same bucket.

1 Like

This did the job, thanks!


1 Like