-
Notifications
You must be signed in to change notification settings - Fork 0
client db
This module provides client-side access to the synchronized data stores. For each happening, there are several different stores available:
- shared, synchronized across all devices of all happening members,
- admin, synchronized across all devices of all happening admins,
- personal, synchronized across all devices of the logged in happening member, and
- local, not synchronized, only available on the local client device.
Except for the local store, these stores can only be modified from your server-side plugin code. Client-side code can read and observe the data though, subject to the above limitations of course. There is one exception: when in a Server.sync prediction function, client-side code is allowed to modify any of the stores. Changes are only temporary though; they will be reverted once a response from the server has been received (which will hopefully apply the same or similar changes).
A read-only Observable that maps to the root of the shared store.
A read-only Observable that maps to the root of the personal store for the logged in user.
A read-only Observable that maps to the root of the shared admin store.
An Observable that maps to the root of the local store.
A simple chat example, client-side code:
Db = require 'db'
Dom = require 'dom'
if messages = Db.shared.ref("messages")
messages.iterate (message) ->
# using reactive iteration, see the obs module for how this works
Dom.div ->
Dom.text message.get('text')
sendMessage = (text) ->
require('server').call "sendMessage", textServer-side code:
Db = require 'db'
exposed.client_sendMessage = (info, text) ->
maxId = Db.shared.modify (v) -> (v||0)+1
Db.shared.set "messages", maxId, {text: text}Also see the db server module reference.
Additionally, there is an admin store that is shared between all happening admin, and a local store: it is writable as well and changes are only saved on the local device. Use it as scratch space.
- [How it works](How it works)
- [Your first plugin](Your first plugin)
- Submitting and distributing your plugin
- Using the Developer Tools
- Example plugins on Github
-
API Reference
- Client
- [client plugin](client plugin)
- [client dom](client dom)
- [client obs](client obs)
- [client db](client db)
- [client server](client server)
- [client page](client page)
- [client ui](client ui)
- [client form](client form)
- [client icon](client icon)
- [client modal](client modal)
- [client photo](client photo)
- [client photoview](client photoview)
- [client time](client time)
- [client share](client share)
- [client map](client map)
- [client geoloc](client geoloc)
- Server
- [server event](server event)
- [server plugin](server plugin)
- [server http](server http)
- [server db](server db)
- [server photo](server photo)
- [server time](server time)
- Client
- Example UI elements