« Back to full topics list
0
0

I am using the document store for several different things inside of the same project now. 1) queuing system, 2) wifi probe caching/metadata, and over the next few days will be implementing more.

Is it appropriate that I’m keeping all of the data in the ‘same place’ in one big bucket for all of these different use cases?

ANSWERED
Marked as spam
Posted by - Asked on April 2, 2017 7:38 pm - 59 views

3 Replies

0
Private reply

Hi Stefan,

The store is a logical and practical partitioning of your data, it is similar to “collections” or “tables” or “buckets”, based on the database technology you’re most familiar with.

Also, each store can have a different ACL allowing only specific users / groups to create documents in it.

While you can put every piece of data you have in one store and then partition based on schemas or a property in each document, it would be better if you partition your data in multiple stores based on functionalities, data types, security or even scalability (like simple sharding).

– Logical Partitioning: in a “shop” solution, you would have your POs in a separate store, not mixed with your catalog.
– Security Partitioning: in an “HR” solution, you would want to put a GATE-ACL (stopping all operations on the store) to the HR group. That way no matter what ACL is set on each document, the store acl will stop them at the gate.

Concerning scalability, when the store grows a lot, some queries might get a performance degradation while it won’t be affected by the size of another store in the same account. This means that you should separate “metadata” like the catalog in the previous example, from the ever growing list of POs (making sure that listing products is only affected by the number of products and not by the number of purchases).

You can also separate your POs into multiple stores, by date or by some other criteria (sharding).

I hope this helps,

Julien Mrad
Scriptr.io Team

Marked as spam
Posted by - Replied on April 3, 2017 10:40 am
0
Private reply

OK. But then it is not clear how the ‘document’ API maps to different stores, as this isn’t referenced in the documentation. I see in the DataExplorer that there is a ‘defaultstore’, I’m assuming that’s the one I am using. Is this where I would create new stores? How do I use them?

Marked as spam
Posted by - Replied on April 3, 2017 3:32 pm
0
Private reply

Stefan,

You can create a store programmatically as follows:

var stores = require("store");

// Create the "myStore" store with the following ACLs
stores.save("myStore", {
    "saveDocumentACL" : "deviceA",
    "deleteDocumentACL" : ["deviceA", "group:firstFloor"],
    "queryACL" : "deviceB",
    "getAttachmentACL" : "deviceB"
});

You can also create stores from the Data Explorer. Under DefaultStore there’s a “new” button which will allow you to create a store from the UI, passing the set of ACLs like saveDocumentACL and queryACL.

As for saving a document in a store from your script, here’s an example of how it’s done:

var documentObj = {
  "payLoad": "your stingyfied payload",
  "meta.schema": "mySchemaName",
  "jobStatus": "queued",
  "failedAttempts":0
};

var documents = require("document");

//This is where you specify the target store
var myStore = documents.getInstance("mySecondStore");
var  result = myStore.create(documentObj);

return result;

Regards,

Julien Mrad
Scriptr.io Team

Marked as spam
Posted by - Replied on April 3, 2017 5:25 pm