Blog

Introducing Collections & how they work

Until now, CRUD based operations were quite useful for the users of JSONbin.io and it will be, but what about those users who are looking to build small applications and need to fetch multiple records?

That's right. Inorder to fetch multiple records, we've introduced a feature called Collections. Now how does this Collection feature exactly work? Here's a visual re-presentation on the working of Collections.

Adding bins to a Collection

In the above workflow, a user, when creates multiple bins, he can use collection-id header and pass a valid Collection ID (will receive one when the user creates a collection), the bins which are created with a mentioned Collection ID will be stored under that collection. Bins which are not added under collection will end-up as an un-categorized bin.

Since we can add the records under specific collection, we can now use a Query Builder (up-coming feature) and fetch multiple records from a specific collection. For example:

In the above image, we try to fetch records from a specific collection, where gender = male. These records will be returned in an array ordered by the date these records were created. Further, you can also provide record limits, sort order, and only return specific keys from each of the object.

Here's how a Query Builder code would look like. (Note: This is just an example, final syntax might be different as the feature is under development.)

Headers to be passed:

collection-id: 2752ab24d***c1 (sample id)

Query

{
  where: {
    gender: "male",
    age: {
      gte: 21 // greater than, equal to
    }
  },
  orderBy: {
    createdAt: "asc"
  }
}

Idea behind developing this feature is to enable users to fetch multiple records and specific records only instead of fetching a single record and then filtering for the relevant ones on their end.

Please refer to our Collection API Reference section for more information.

Note that the Query Builder feature is under development and will be released soon. Until then, adding features in a collection is not much useful as you can't fetch them without a query. We will publish another article when we conclude the final workflow and syntax for the Query Builder, until then, keep creating collections and keep adding the records to a collection.

There are few API which will be introduced at a later stage, i.e, to DELETE these collections, moving the records from one collction to another and so on.


TL;DR

We've developed a feature called Collections where a user can categorize these records and fetch multiple based on the conditions they provide. Users need to use JSONbin's Query Builder to fetch multiple records. Query Builder is under development.