Best Practice for linking or combining documents in different buckets?

17 views
Skip to first unread message

ml10

unread,
Jun 4, 2012, 12:28:10 PM6/4/12
to terrastore-...@googlegroups.com
My use case for Terrastore involves combining an action and a resource into 1 document for consumption by external users over the HTTP API. Currently the actions are under the action bucket and resources are under the resource bucket.

action/1111
action/1122
resource/db1
resource/db2

action/1111 = { "path" : "/some/path", "sw_version: "3.4.5", "resource" : "resource/db2" }
resource/db2 = { "url" : "http://some.url/", "username" : "un", "password" : "pw", "db_name" : "mydb", "data_file" : "/another/path", "log_file" : "/third/path" }

I'd like to be able to provide some way to combine all of this information together, so I could get a result like this, referenced by action (it wouldn't be necessary to include the resource as long as it's contents are included):
{ "path" : "/some/path", "sw_version: "3.4.5", "resource" : "db2", "url" : "http://some.url/", "username" : "un", "password" : "pw", "db_name" : "mydb", "data_file" : "/another/path", "log_file" : "/third/path" } 

I'd prefer not to modify the original documents.

For something like this would you recommend terrastore.event.EventListener(s) on the action and resource buckets to keep a third document in sync, a custom terrastore.store.operators.Function to return the combined data, or something else?

I'll try a couple things, but was just curious if there was a recommended approach.

Thanks.

Sergio Bossa

unread,
Jun 5, 2012, 1:07:22 PM6/5/12
to terrastore-...@googlegroups.com
I think EventListeners are exactly what you're looking for.
Otherwise, you could just read the resource before writing the action
and then write both the action and the compound document.

Keep us posted about your solution.
Cheers!

Sergio B.
--
Sergio Bossa
http://www.linkedin.com/in/sergiob
Reply all
Reply to author
Forward
0 new messages