Skip to content

server db

Frank van Viegen edited this page Sep 9, 2015 · 2 revisions

server: db

This module provides server-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 a single happening member; note that this is not a single data store, but in fact one store for each member, and
  • backend, not synchronized, only available to your backend code.

Data in any of these stores can only be modified by your server-side plugin code. Client-side code can read and observe the data though, subject to the above limitations of course.

Objects

shared

An Observable that maps to the root of the shared store.

admin

An Observable that maps to the root of the shared admin store.

Functions

personal(memberId)

Returns a Observable that maps to the root of the personal store for the given member id.

Example

Example:

server.coffee:
	Db = require 'db'

	exports.client_add = (data) !->
		# allocate a the next id; when `maxId` isn't set yet, this will set and return 1
		id = Db.shared.incr 'maxId'

		# add entree to the list
		Db.shared.set 'items', id, data

client.coffee:
	Dom = require 'dom'
	Ui = require 'ui'
	Modal = require 'modal'
	Server = require 'server'

	Dom.section !->
		Dom.h4 "A shared list"
		Ui.list !->
			Db.shared.iterate 'items', (myItem) !->
				Ui.item !->
				Dom.text myItem.get()
			Ui.bigButton "Add", !->
				Modal.prompt "Add new item", (value) !->
					Server.call 'add', value

Basic topics

API reference

  • 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)
  • Example UI elements

Advanced topics

Clone this wiki locally