Sail the high seas with ScuttleBoat
Like Scuttlebucket, but allows for dynamically adding records later
var ScuttleBoat = var Model = // Define sub-document constructor types opts = constructors: Model: Model // Setup ScuttleBoats A = optsB = opts var as = Avar bs = B as // Dynamically add sub-documents aMeta = AaMeta // Subdocuments are created and synced
API
Add a sub-document to the boat. The sub-document instance will be created automatically. Provide:
- the key (string)
- the type from the list of constructors (string)
- an (optional) argument to instantiate the instance with. Argument must be serializable. Cannot provide more than one initialization argument.
boat
Get a list of all subdocs
boat //=> {key1: subdoc1, key2: subdoc2, ...}
Clone a scuttleboat instance
boat
Listen for new subdocs
boat