How to Programatically Count Key Value Pairs in a Datastore?

This topic was automatically generated from Slack. You can find the original thread here.

How do i check how many key value pairs there are in a datastore? We have a lot in there so there doesn’t seem to be an easy way to count using the UI. Is there a way programmatically?

Hi , you can create a Node.js code step to retrieve a list of keys, and simply get the length of that list. For example:

export default defineComponent({
  props: {
    data: { type: "data_store" },
  },
  async run({ steps, $ }) {
    // Return a list of all the keys in a given Data Store
    return (await this.data.keys()).length;
  },
})

isn’t the match 1024 keys? If the datastore is 50k keys how would you address this?