Object Store makes operations to store any document in the Object Store of Digibee. It's a simple and quick way to save useful JSON-type information, which has operations to help in multiple uses during the creation of a pipeline.

Take a look at the configuration parameters of the component:

  • Account: account to be used by the component. This item can't be changed.

  • Operation: operation to be executed inside Object Store - Find by Object ID, Find By Query, Insert, Aggregate, Update By Object Id, Update By Query, Delete By Object Id and Delete By Query. This item supports Double Braces.

  • Object Store Name: name of the collection to be used to record or read information. If it doesn't exist, it will be automatically created.

  • Object ID: identifier of the object to be stored or searched. It can be an unique number or an UUID. This item supports Double Braces.

  • Limit: maximum number of objects to be returned in a search. This item supports Double Braces.

  • Skip: amount of objects to be skipped before returning to the query. This parameter is usually used along with the “Limit” parameter to create a way of pagination. This item supports Double Braces.

  • Sort: specification of the query ordination rules.

  • Unique Index: if the option is activated, an Object ID will be created to accept unique values only; otherwise, a non-unique index will be created.

  • Isolated: if the option is activated, all the queries will be delimited in the execution scope.

  • Upsert: this item appears only if the "Operation" parameter is Update By Object Id or Update By Query. When this item is activated, the item informed for the object will be inserted in the collection in case it doesn't exist.

  • Fail On Error: if the option is enabled, the execution of the pipeline with error will be interrupted; otherwise, the pipeline execution proceeds, but the result will show a false value for the “success” property.

Some of the parameters above accept Double Braces. To understand how this language works, read our article by clicking here.

Messages flow

Input

For this specific component, the only mandatory input message pattern is the JSON format applied to the object. The input parameter can use the Double Braces syntax to send the received message to the component.

Output

  • Insert

{
"data": [],
"updateCount": 1
}

  • Find

{
"data": [
{
"name": "Galaxy s20",
"uuid": "123",
"_oId": "1"
}
],
"rowCount": 1
}

  • Update

{
"data": [],
"updateCount": 1
}

  • Delete

{
"data": [],
"updateCount": 1
}

  • Aggregate

{
"data": [],
"rowCount": 0
}

Object Store in Action

Some output examples of each operation were shown above. See below more applications that demonstrate the correct configuration for a determined result to be obtained:

  • Insert multiple items at once in a collection

When sending an object array in the query field, the component inserts each item in a separate way inside the selected collection.

Observe how to configure the component with the "Operation: Insert", "Unique Index: False" and "Query" parameters:

[
{
"id": 1,
"name": "Galaxy s20",
"price": 5000
},
{
"id": 2,
"name": "Samsung 4k 55\"",
"price": 5000
},
{
"id": 3,
"name": "Galaxy A10",
"price": 699
},
{
"id": 4,
"name": "Galaxy A51",
"price": 1620
}
]

Output

{
"data": [],
"updateCount": 4
}

IMPORTANT: the insertion of multiple objects at once is allowed in collections created with "Unique Index: false" only. The Unique Index property is defined in the collection creation. After the index is created, it's not possible to change the property.

  • Find items from a determined query

As an example, consider an Object Store that already has registered product-type items and whose characteristics are name and price.

Observe how to configure the component with the "Operation: Find By Query" and "Query" parameters:

{
"product.price": { $gt: 2000 }
}

Output

{
"data": [
{
"product": {
"id": 1,
"name": "Galaxy s20",
"price": 5000
},
"_oId": "1"
},
{
"product": {
"id": 2,
"name": "Samsung 4k 55\"",
"price": 5000
},
"_oId": "2"
}
],
"rowCount": 2
}

  • Find all the items from a query

As an example, consider an Object Store that already has registered product-type items and whose characteristics are name and price.

Observe how to configure the component with the "Operation: Find By Query", "Limit: 10" and "Query" parameters:

{}

Output

{
"data": [
{
"product": {
"id": 1,
"name": "Galaxy s20",
"price": 5000
},
"_oId": "1"
},
{
"product": {
"id": 2,
"name": "Samsung 4k 55\"",
"price": 5000
},
"_oId": "2"
},
{
"product": {
"id": 3,
"name": "Galaxy A10",
"price": 699
},
"_oId": "3"
},
{
"product": {
"id": 4,
"name": "Galaxy A51",
"price": 1620
},
"_oId": "4"
}
],
"rowCount": 4
}

In this specific scenario, the limit parameter was configured so there wouldn't be an unnecessary overload when returning the objects from an Object Store. If the option isn't configured that way, an "Out Of Memory" error can occur inside the pipeline. In the indicated way, there's control over how many objects are seen in the response.

  • Update an item from a specific ID

As an example, consider an Object Store that already has registered product-type items and whose characteristics are name and price.

Observe how to configure the component with the "Operation: Update By Object Id", "Object Id: 3" and "Document" parameters:

{
$set: {
"product": {
"id": 3,
"name": "Galaxy A10",
"price": 605
}
}
}

Output

{
"data": [],
"updateCount": 1
}

In this specific scenario, it's possible to see that the output is only an object identifying an update. To check if the object has been properly updated, repeat the ID search scenario.

IMPORTANT: if the Object Store component is involved in updates, inside an iteration component (For Each, Stream File Reader, etc.) and making parallel executions, there can be concurrence in the registers update if the update instructions are exactly the same. Consequently, one instruction will return "updateCount":1 and the other "updateCount": 0. It happens when 2 registers that are exactly the same get into the Object Store operation pool and the update or insertion instructions (enabled UPSERT) are sequentially executed. The first instruction makes an update and the second one finds the already-persisted register and checks there's nothing to be changed, returning there was no need for an action ("updateCount": 0).

  • Remove an item from a specific ID

As an example, consider an Object Store that already has registered product-type items and whose characteristics are name and price.

Observe chow to configure the component with the "Operation: Delete By Object Id", "Object Id: 4" parameters.

Output

{
"data": [],
"updateCount": 1
}

In this specific scenario, it's possible to see that the output is only an object that identifies the update. To check if the object has been properly updated, repeat the ID search scenario.

  • Aggregation to copy the collection

As an example, consider an Object Store called product that already has registered product-type items and whose characteristics are name and price. From that, create a new Object Store called product-backup, copying all the items of the collection mentioned above.

You must receive an object array containing the query aggregation pipelines in the “document” parameter.

Observe how to configure the component with the "Operation: Aggregate" and "Query" parameters:

[
{
$merge: {
into: "product-backup",
on: "_id",
whenMatched: "replace",
whenNotMatched: "insert"
}
}
]

In this specific scenario, the query was configured to replace the repeated items with the new ones in the collection.

Output

{
"data": [],
"rowCount": 0
}

To check if the collection has been properly created with the proposed items, repeat the search scenario with all the items and inform the new collection.

  • Aggregation to filter collection items

You must receive an object array containing the query aggregation pipelines in the “document” parameter.

Observe how to configure the component with the "Operation: Aggregate" and "Query" parameters:

[
{
$match: {
"product.price": {
$gt: 3000
}
}
},
{
$group: {
_id: null,
count: {
$sum: 1
}
}
}
]

In this specific scenario, the query was configured to search products that has a determined value and to show their sum.

Output

{
"data": [
{
"count": 2
}
],
"rowCount": 0
}

Technology

Object Store uses search operators and objects aggregation similar to the MongoDB syntax. To know it, click here.

Did this answer your question?