graph-database.js
/**
   Commmit accumulated changes to the remote store.
   Iterate over the owned object stores, collect their delete/post/put patches,
   delegate to the database with this collected patch.
   When that completes, clear the state on all registered objects and
   record the new revision id in the database.

   This returns no additional asynchronous control thread as, when invoked from
   a control thread in the database, this invocation is either already in an
   asynchronous, as a promise's then function.
   For an explicit invocation from the application thread return a request
   instance which can bind an onsuccess property to recieve control when the
   patch request completes.
   */
Commmit accumulated changes to the remote store.
Iterate over the owned object stores, collect their delete/post/put patches,
delegate to the database with this collected patch.
When that completes, clear the state on all registered objects and
record the new revision id in the database.

This returns no additional asynchronous control thread as, when invoked from
a control thread in the database, this invocation is either already in an
asynchronous, as a promise's then function.
For an explicit invocation from the application thread return a request
instance which can bind an onsuccess property to recieve control when the
patch request completes.
Commmit accumulated changes to the remote store . Iterate over the owned object stores collect their delete / post / put patches delegate to the database with this collected patch . When that completes clear the state on all registered objects and record the new revision id in the database . This returns no additional asynchronous control thread as when invoked from a control thread in the database this invocation is either already in an asynchronous as a promise ' s then function . For an explicit invocation from the application thread return a request instance which can bind an onsuccess property to recieve control when the patch request completes .
commit() {
    console.log(`GDBTransaction.commit @${this.revisionID}`, this);
    var posts = [];
    var puts = [];
    var deletes = [];
    this.stores.forEach(function(store) {
      var patch = store.asPatch();
      deletes = deletes.concat(patch.delete ? patch.delete.statements : []);
      posts = posts.concat(patch.post ? patch.post.statements : []);
      puts = puts.concat(patch.put ? patch.put.statements : []);
    });
    var request = new CommitRequest(this, this);
    var thisTransaction = this;
    var p = this.database.patch({delete: deletes, post: posts, put: puts},
                                {contentDisposition: this.disposition,
                                 etag: this.revisionID},
                                function(response) {
                                  thisTransaction.cleanObjects();
                                  if (response.onsuccess) {
                                    response.onsuccess(new SuccessEvent("success", "commit", response.result));
                                  }
                                  var etag = response.headers.get("etag");
                                  if (etag) {
                                    thisTransaction.database.revision = etag;
                                  }
                                  console.log(`GDBTransaction.commit @${thisTransaction.revisionID} complete`);
                                  return (response) ;
                                });
    return (request);
  }
commit ( ) { console . log ( ` ${ this . revisionID } ` , this ) ; var posts = [ ] ; var puts = [ ] ; var deletes = [ ] ; this . stores . forEach ( function ( store ) { var patch = store . asPatch ( ) ; deletes = deletes . concat ( patch . delete ? patch . delete . statements : [ ] ) ; posts = posts . concat ( patch . post ? patch . post . statements : [ ] ) ; puts = puts . concat ( patch . put ? patch . put . statements : [ ] ) ; } ) ; var request = new CommitRequest ( this , this ) ; var thisTransaction = this ; var p = this . database . patch ( { delete : deletes , post : posts , put : puts } , { contentDisposition : this . disposition , etag : this . revisionID } , function ( response ) { thisTransaction . cleanObjects ( ) ; if ( response . onsuccess ) { response . onsuccess ( new SuccessEvent ( "success" , "commit" , response . result ) ) ; } var etag = response . headers . get ( "etag" ) ; if ( etag ) { thisTransaction . database . revision = etag ; } console . log ( ` ${ thisTransaction . revisionID } ` ) ; return ( response ) ; } ) ; return ( request ) ; }
Commmit accumulated changes to the remote store.
Commmit accumulated changes to the remote store .
// iterate over the owned stores; // for each, get its delta graph // pass the collected operations through to the remote Graph // console.log("commit response", response); // console.log("headers", response.headers); // for (var [k,v] of response.headers.entries()) {console.log([k,v])};