Usage

This library is currently incomplete, and only implements the features I need
for the redpanda project. I intend to end up with a complete implementation of
the fauna v1 API, so please file an issue or contact me (Twitter & email
below) if you have suggestions, bug reports, or patches.

Models

Fauna works with "classes" and "instances" which should map to models and
objects in your app.

A model is a prototype that extends fauna.Class. For example, here's a model
for a song in coffeescript:

The static call @field registers "title" and "rating" as fields in your
javascript object that should be submerged into the 'data' JSON blob when
storing an object in fauna.

Similarly, @reference registers "artist" as a field that refers to another
object stored in fauna. It will be stored by instance ID in the 'references'
JSON blob. Fauna will usually follow references when fetching objects (at
least one or two levels deep), so when reading a Song object, the "artist"
field may contain another full object.

The @field and @reference calls can be used as many times as you want
within a single class, or you may list all the relevant fields on a single
line (like above), Check out the fauna documentation for more details about
the 'data' and 'references' fields on stored instances.

The fauna class name can be inferred (the lowercase name of the model class,
plus an 's') or declared explicitly with @faunaClass:

classSongextendsfauna.Class@faunaClass"all_songs"

Event sets

Custom event sets can be declared on a model class with @eventSet:

classAlbumextendsfauna.Class@eventSet"tracks"

This will create a special field 'tracks' on any Album object, which refers to
an object with methods for manipulating the set. The methods are:

add(object)

Add an object to an event set. The object must already exist in fauna and
be the result of some previous fauna-js call or passed to `createInstance'.
It may be a fauna instance ID instead of an object, for convenience.

remove(object)

Remove an object from an event set. The same restrictions apply as add.

page(params)

Fetch the objects that were added to an event set within a time range. The
default time range is infinite, or listing every object currently in the
set. Paramaters are count (maximum number of objects to fetch), before,
and after (tags returned by a previous result). The result is an object
with the items in items, and the before/after tags in before and
after.