sqlite-dynamic.js
function( collectionID, key ) {
            collectionID = collectionID.toLowerCase();

            var deferred = q.defer();

            // acquire a connection from the pool
            db.getClient().then( function(dbClient) {
                if ( !dbClient ) {
                   throw Error("Failed to acquire sqlite client");
                }

                // start a transaction using the acquired db connection
                startTx(dbClient)
                .then( function() {
                    var sql = sqlAdaptor.createDeleteSQL(collectionID, key);
                    return query(dbClient, sql);
                })

                // commit the transaction if no problems are encountered, this should also close the acquired db client
                // and return it to the connection pool
                .then( function(r) {
                    return commitTx(dbClient).then(
                        function() {
                            deferred.resolve(r);
                        }
                    );
                })

                // ultimately rollback if there is any upstream thrown exception caught
                .catch( function(e) {
                    return rollbackTx(dbClient, e).finally( function() {
                        deferred.reject(e);
                    });
                })

                // always try to release the client, if it exists
                .finally(function() {
                    if ( dbClient ) {
                        // always try to release the client, if it exists
                        dbClient.release();
                    }
                });
            })
            // failed to acquire the client
            .fail( function(e) {
                deferred.reject(e);
            });

            return deferred.promise;
        }
function( collectionID, key ) {
            collectionID = collectionID.toLowerCase();

            var deferred = q.defer();

            // acquire a connection from the pool
            db.getClient().then( function(dbClient) {
                if ( !dbClient ) {
                   throw Error("Failed to acquire sqlite client");
                }

                // start a transaction using the acquired db connection
                startTx(dbClient)
                .then( function() {
                    var sql = sqlAdaptor.createDeleteSQL(collectionID, key);
                    return query(dbClient, sql);
                })

                // commit the transaction if no problems are encountered, this should also close the acquired db client
                // and return it to the connection pool
                .then( function(r) {
                    return commitTx(dbClient).then(
                        function() {
                            deferred.resolve(r);
                        }
                    );
                })

                // ultimately rollback if there is any upstream thrown exception caught
                .catch( function(e) {
                    return rollbackTx(dbClient, e).finally( function() {
                        deferred.reject(e);
                    });
                })

                // always try to release the client, if it exists
                .finally(function() {
                    if ( dbClient ) {
                        // always try to release the client, if it exists
                        dbClient.release();
                    }
                });
            })
            // failed to acquire the client
            .fail( function(e) {
                deferred.reject(e);
            });

            return deferred.promise;
        }
function ( collectionID , key ) { collectionID = collectionID . toLowerCase ( ) ; var deferred = q . defer ( ) ; // acquire a connection from the pool db . getClient ( ) . then ( function ( dbClient ) { if ( ! dbClient ) { throw Error ( "Failed to acquire sqlite client" ) ; } // start a transaction using the acquired db connection startTx ( dbClient ) . then ( function ( ) { var sql = sqlAdaptor . createDeleteSQL ( collectionID , key ) ; return query ( dbClient , sql ) ; } ) // commit the transaction if no problems are encountered, this should also close the acquired db client // and return it to the connection pool . then ( function ( r ) { return commitTx ( dbClient ) . then ( function ( ) { deferred . resolve ( r ) ; } ) ; } ) // ultimately rollback if there is any upstream thrown exception caught . catch ( function ( e ) { return rollbackTx ( dbClient , e ) . finally ( function ( ) { deferred . reject ( e ) ; } ) ; } ) // always try to release the client, if it exists . finally ( function ( ) { if ( dbClient ) { // always try to release the client, if it exists dbClient . release ( ) ; } } ) ; } ) // failed to acquire the client . fail ( function ( e ) { deferred . reject ( e ) ; } ) ; return deferred . promise ; }
Remove a piece of data from a name collection, based to the provided key, return promise
containing removed items when done.
If no key is provided, all the data from the collection is removed.
Is transactional - will rollback on error.
@param collectionID
@param key
Remove a piece of data from a name collection based to the provided key return promise containing removed items when done . If no key is provided all the data from the collection is removed . Is transactional - will rollback on error .