Hi, I’m trying to build a simple accounting app with remotestorage.
I have some customers stored under /customers/ and some bills stored under /bills/.
Each customer and each bill is stored as a JSON object. For each bill, the customer_id is stored.
Now I want to provide an overview of all bills including the names of the customers. These names are not stored in the bill objects, but in the customer objects.
Is there a way to perform a JOIN operation on the server side using remotestorage, that would return the bills with their customer names in them (something like SELECT * FROM bills, customers WHERE bill.customer_id = customer.id)? Or is there a different way you could tackle this problem when using remotestorage?
RemoteStorage servers basically present a simple filesystem to you, so serverside JOINs like you describe are absolutely impossible.
I recommend having filepaths like
/customers/mycustomer/bills/mybill, such that you can “select” all bills of a customer X by listing the content of
/customers/X/bills/. This assumes that filtering by customer is the most common filtering method, otherwise you’ll have to figure out a more sophisticated method (manually maintaining indices and such).
Personally I’d wish for a ORM that does all of this for you, but I don’t see it happening anytime soon.
Great, thanks untiaker. I’m gonne go with your approach.
BTW, is there a possibility to create indices automatically? (like a sorted list of all bills)
I’m not aware of something like that existing.
You’d usually do things like sorting with the objects in memory within your app (framework). In Sharesome, I’m using timestamps in the filenames in order to sort from the listing before even fetching objects.