How to write a server query that works on both hub and cloud

33 views
Skip to first unread message

Scott Erholm

unread,
Feb 6, 2017, 3:32:25 PM2/6/17
to zetta-discuss
I'm having troubles writing an app which is capable of listening for a device regardless of whether it's running on the hub or on a cloud server.

The query is like:
var q = server.from('*').where({name:foo});

This works fine on the cloud peer server, but does not work on the hub.  Reading a few other threads here, it seems as though the from('*') statement does not match on the hub.

I would like one version of the app, regardless of where it is running, and would rather not have to resort to separate config files or some such mechanism.  How to write the query so that it matches on the local hub as well as on the remote peer?

Kevin Swiber

unread,
Feb 6, 2017, 3:44:30 PM2/6/17
to Scott Erholm, zetta-discuss
Hey Scott,

I haven't tested it, but I think you can do something like:

```js
var o1 = server.observe(server.from('*').where({name: 'foo'}));
var o2 = server.observe(server.where({name: 'foo'}));

var Observable = require('rx').Observable;

Observable.merge(o1, o2).subscribe(function(device) { ... });
```


Cheers,

Kevin

--
You received this message because you are subscribed to the Google Groups "zetta-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zetta-discus...@googlegroups.com.
To post to this group, send email to zetta-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/zetta-discuss/ec355f7f-4825-4581-853a-222fa410f0f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages