Coder Social home page Coder Social logo

sails-mysql-transactions's Introduction

Sails MySQL Transactional ORM with replication support

sails-mysql-transaction is a Sails ORM Adapter for MySQL with transaction and replication cluster support.

This adapter essentially wraps around the popular sails-mysql adapter and provides additional API to perform operations that ties around a database transaction. It also provides to read from a cluster of read-replicas in a load-balanced fashion.

Installation

  1. Add sails-mysql-transactions to your application’s package.json. Do not run install directly if sails is not already installed in your package.

  2. If you already have sails-mysql installed, it might interfere with operations of this module. Remove it from your package.json and uninstall the same using npm remove sails-mysql.

  3. This package installs successfully only when sails is already installed in the package. If the package is already installed, then simply run npm install sails-mysql-transactions --save, otherwise run npm install and it will take care of rest.

Safe install using postinstall script

If npm install seems erratic to install dependencies in order, you could add the following in your package.json as a postinstall script of npm. This would ensure that this module is installed after sails has been completely installed. Note that in this method, you would not need to add sails-mysql-transactions as a dependency in your package.json

{
  "scripts": {
    "postinstall": "npm install sails-mysql-transactions"
  }
}

Installation Notes:

This package overwrites the waterline module inside Sails with a fork of Waterline maintained by Postman. As such, if you ever re-install or update sails, ensure you re-install this adapter right after it.

Do check SailsJS compatibility list before upgrading your Sails version while already using this adapter.

Quick Start

The integration test Sails App located in tests/integration/app directory of this repository has a fully functional installation. Simply run npm install within test/integration/app directory.

Sails config/local.js

module.exports = {
  /* your other config stay as is */
  
  connections: {
    mySQLT: {
      adapter: 'sails-mysql-transactions',
      host: '{{your-db-host}}',
      user: '{{your-db-username}}',
      password: '{{your-db-password}}',
      database: '{{your-db-tablename}}',

      transactionConnectionLimit: 10,
      rollbackTransactionOnError: true,
      queryCaseSensitive: false,

      /* this section is needed only if replication feature is required */
      replication: {
        enabled: true,
        inheritMaster: true,
        canRetry: true,
        removeNodeErrorCount: 5,
        restoreNodeTimeout: 1000 * 60 * 5,
        defaultSelector: 'RR', // 'RANDOM' or 'ORDER'
        sources: { 
          readonly: {
            enabled: true,
            host: '{{replica-1-host}}',
            user: '{{replica-1-user}}',
            password: '{{replica-1-password}}'
          }
        }
      }
    }
  },

  models: {
    connection: 'mySQLT'
  }
}

Use Transaction in your controllers

var Transaction = require('sails-mysql-transactions').Transaction;

module.exports = {
  create: function (req, res) {
    // start a new transaction
    Transaction.start(function (err, transaction) {
      if (err) {
        // the first error might even fail to return a transaction object, so double-check.
        transaction && transaction.rollback();
        return res.serverError(err);
      }

      OneModel.transact(transaction).create(req.params.all(), function (err, modelInstance) {
        if (err) {
          transaction.rollback();
          return res.serverError(err);
        }

        // using transaction to update another model and using the promises architecture
        AnotherModel.transact(transaction).findOne(req.param('id')).exec(function (err, anotherInstance) {
          if (err) {
            transaction.rollback();
            return res.serverError(err);
          }

          // using update and association changes
          modelInstance.someAssociatedModel.remove(req.param('remove_id'));

          // standard .save() works when in transaction
          modelInstance.save(function (err, savedModel) {
            if (err) {
              transaction.rollback();
              return res.serverError(err);
            }

            // finally commit the transaction before sending response
            transaction.commit();
            return res.json({
              one: savedModel,
              another: anotherInstance
            });
          });
        });
      });
    });
  }
};

List of available transactional operations:

route = function (req, res) {
  Transaction.start(function (err, transaction) {
    OneModel.transact(transaction).create(/* ... */);
    OneModel.transact(transaction).update(/* ... */);
    OneModel.transact(transaction).find(/* ... */);
    OneModel.transact(transaction).findOrCreate(/* ... */);
    OneModel.transact(transaction).findOne(/* ... */);
    OneModel.transact(transaction).destroy(/* ... */);
    OneModel.transact(transaction).count(/* ... */);
  });
};

Other than those, update, save and association operations on instance methods work within transaction provided they were either stemmed from the same transaction or wrapped (transaction.wrap(instance)) by a transaction.

Exceptions where transactions may fail

In cases where you are performing model instance opertaions such as save, destroy, etc on instances that has been stemmed from a .populate, transaction might fail. In such scenarios, performing a transaction.wrap(instance); before doing instance operations should fix such errors.

If you want to selectively intercept errors from this module, compare using instanceof Transaction.AdapterError.

Note that this adapter adds an additional auto column called transactionId. If you do not want to use transaction on a particular model, you can turn off creation of this column by setting autoTK: false in your model.

Support for Read Replicas

When one or more read replica sources are provded, the following API can be used to access data from one of the defined replication source databases. This distributes your database workloads across multiple systems.

Readonly still works without read replica using the normal non-transactional connection set.

action = function (req, res) {
  OneModel.readonly().find();
  OneModel.readonly().findOne();
  OneModel.readonly().count();
};

Support to retrieve changesets during update operations

Since sails-mysql makes a SELECT query before every update; it makes sense that the query results can be utilised to return the changeset when a model is updated. The third parameter of .update returns an array having objects that contain only the fields that have changed and that too with their original values.

Additional Configurations and Features

  1. queryCaseSensitive when set to true, disables the feature where waterline performs case insensitive queries. (Note that it ises wlNext options for waterline-sequel.)

  2. The bundled waterline adds additional feature to do the following

  • Model.<function:operate>().populateSome(Object<association:criteria>); allows you to populate multiple associations in one call. It also accepts array of associations as argument
  • .populate on Models accepts select: [] as part of criteria parameter.
  • Model deletion does not fetch full model data during deletion.
  1. An additional asynchronous function fromObject() which creates a model instance based on the model attributes.
  • This function accepts the attributes object and the callback function as the parameter.
  • The callback function will receive the error object and the Model Instance object
OneModel.fromObject(attributesObject, function (err, instance) {
    if (err) { return Error; }
    
    // instance is the required object
});

Contributing

Contribution is accepted in form of Pull Requests that passes Travis CI tests. You should install this repository using npm install -d and run npm test locally before sending Pull Request.

sails-mysql-transactions's People

Contributors

ankitjaggi avatar elssar avatar shamasis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sails-mysql-transactions's Issues

Incorrect integer value for column 'transactionId'

I am using mysql. At the beginning, I set the transactionId int(11). It's ok. But when I put the database upgrade to 0.5.6, has this error:
[Error (E_UNKNOWN) Encountered an unexpected error] Details: Error: ER_TRUNCATED_WRONG_VALUE_FOR_FIELD: Incorrect integer value: 'b755f847-0fa9-4efa-aab8-3e6a475d98b4' for column 'transactionId' at row 1

what is the data type of transactionId?

Transaction not working with create model

Hi Sorry for my english .
When i create a data for model a. In this case , i try make another model with find error but transaction not working (blank data not working for model a)

Installation fails for window

Hi,

I tried to install the package according to the given instructions. But it doesn't work on Windows 7.
I get the following error:

[email protected] postinstall D:\testProj\node_modules\sails-mysql-transactions
scripts/postinstall.sh

'scripts' is not recognized as an internal or external command,

Travis build failing while installing sails-mysql-transaction

I am using [email protected], [email protected] and [email protected].
Package json has following scripts:

"scripts": {
    "predeploy": "npm install -g",
    "preinstall": "npm remove sails-mysql",
    "start": "BLUEBIRD_W_FORGOTTEN_RETURN=0 sails lift",
    "postinstall": "npm install [email protected]"
  },

Travis build is throwing following error while installing sails.

> sails@0.12.1 preinstall /home/travis/build/practo/consumer-payments-api/node_modules/sails
> node ./lib/preinstall_npmcheck.js
Sails.js Installation: Checking npm-version successful
npm WARN deprecated wrench@1.5.9: wrench.js is deprecated! You should check out fs-extra (https://github.com/jprichardson/node-fs-extra) for any operations you were using wrench for. Thanks for all the usage over the years.
npm WARN deprecated native-or-bluebird@1.1.2: 'native-or-bluebird' is deprecated. Please use 'any-promise' instead.
npm WARN optional dep failed, continuing fsevents@1.0.12
npm WARN deprecated graceful-fs@3.0.8: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated lodash@2.4.1: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0.
npm WARN deprecated cross-spawn-async@2.2.4: cross-spawn no longer requires a build toolchain, use it instead!
> kerberos@0.0.11 install /home/travis/build/practo/consumer-payments-api/node_modules/db-migrate/node_modules/mongodb/node_modules/kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory `/home/travis/build/practo/consumer-payments-api/node_modules/db-migrate/node_modules/mongodb/node_modules/kerberos/build'
  CXX(target) Release/obj.target/kerberos/lib/kerberos.o
make: Leaving directory `/home/travis/build/practo/consumer-payments-api/node_modules/db-migrate/node_modules/mongodb/node_modules/kerberos/build'
> [email protected] install /home/travis/build/practo/consumer-payments-api/node_modules/db-migrate/node_modules/mongodb/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory `/home/travis/build/practo/consumer-payments-api/node_modules/db-migrate/node_modules/mongodb/node_modules/bson/build'
  CXX(target) Release/obj.target/bson/ext/bson.o
make: Leaving directory `/home/travis/build/practo/consumer-payments-api/node_modules/db-migrate/node_modules/mongodb/node_modules/bson/build'
> [email protected] install /home/travis/build/practo/consumer-payments-api/node_modules/db-migrate/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build
[sqlite3] Success: "/home/travis/build/practo/consumer-payments-api/node_modules/db-migrate/node_modules/sqlite3/lib/binding/node-v46-linux-x64/node_sqlite3.node" is installed via remote
npm ERR! fetch failed https://registry.npmjs.org/escape-regexp/-/escape-regexp-0.0.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
npm ERR! fetch failed https://registry.npmjs.org/machinepack-urls/-/machinepack-urls-3.1.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
npm ERR! fetch failed https://registry.npmjs.org/escape-regexp/-/escape-regexp-0.0.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
npm ERR! fetch failed https://registry.npmjs.org/machinepack-urls/-/machinepack-urls-3.1.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
npm ERR! fetch failed https://registry.npmjs.org/escape-regexp/-/escape-regexp-0.0.1.tgz
npm ERR! fetch failed https://registry.npmjs.org/machinepack-urls/-/machinepack-urls-3.1.1.tgz
npm ERR! Linux 3.13.0-63-generic
npm ERR! argv "/home/travis/.nvm/versions/node/v4.4.4/bin/node" "/home/travis/.nvm/versions/node/v4.4.4/bin/npm" "install"
npm ERR! node v4.4.4
npm ERR! npm  v2.15.1
npm ERR! fetch failed with status code 502
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR!     /home/travis/build/practo/consumer-payments-api/npm-debug.log
The command "eval npm install " failed. Retrying, 2 of 3.
> [email protected] preinstall /home/travis/build/practo/consumer-payments-api
> npm cache -f clean && npm remove sails-mysql
npm WARN using --force I sure hope you know what you are doing.
npm WARN uninstall not installed in /home/travis/build/practo/consumer-payments-api/node_modules: "sails-mysql"
> [email protected] preinstall /home/travis/build/practo/consumer-payments-api/node_modules/sails
> node ./lib/preinstall_npmcheck.js
Sails.js Installation: Checking npm-version successful
npm WARN deprecated [email protected]: 'native-or-bluebird' is deprecated. Please use 'any-promise' instead.
npm WARN optional dep failed, continuing [email protected]
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0.
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated [email protected]: cross-spawn no longer requires a build toolchain, use it instead!
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm ERR! fetch failed https://registry.npmjs.org/escape-regexp/-/escape-regexp-0.0.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
npm ERR! fetch failed https://registry.npmjs.org/machinepack-urls/-/machinepack-urls-3.1.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
npm ERR! fetch failed https://registry.npmjs.org/escape-regexp/-/escape-regexp-0.0.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
npm ERR! fetch failed https://registry.npmjs.org/machinepack-urls/-/machinepack-urls-3.1.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
npm ERR! fetch failed https://registry.npmjs.org/escape-regexp/-/escape-regexp-0.0.1.tgz
npm ERR! fetch failed https://registry.npmjs.org/machinepack-urls/-/machinepack-urls-3.1.1.tgz
npm ERR! Linux 3.13.0-63-generic
npm ERR! argv "/home/travis/.nvm/versions/node/v4.4.4/bin/node" "/home/travis/.nvm/versions/node/v4.4.4/bin/npm" "install"
npm ERR! node v4.4.4
npm ERR! npm  v2.15.1
npm ERR! fetch failed with status code 502
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR!     /home/travis/build/practo/consumer-payments-api/npm-debug.log
The command "eval npm install " failed. Retrying, 3 of 3.
> [email protected] preinstall /home/travis/build/practo/consumer-payments-api
> npm cache -f clean && npm remove sails-mysql
npm WARN using --force I sure hope you know what you are doing.
npm WARN uninstall not installed in /home/travis/build/practo/consumer-payments-api/node_modules: "sails-mysql"
> [email protected] preinstall /home/travis/build/practo/consumer-payments-api/node_modules/sails
> node ./lib/preinstall_npmcheck.js
Sails.js Installation: Checking npm-version successful
npm WARN deprecated [email protected]: 'native-or-bluebird' is deprecated. Please use 'any-promise' instead.
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN optional dep failed, continuing [email protected]
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0.
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: cross-spawn no longer requires a build toolchain, use it instead!
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm ERR! fetch failed https://registry.npmjs.org/escape-regexp/-/escape-regexp-0.0.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
npm ERR! fetch failed https://registry.npmjs.org/machinepack-urls/-/machinepack-urls-3.1.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
npm ERR! fetch failed https://registry.npmjs.org/escape-regexp/-/escape-regexp-0.0.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
npm ERR! fetch failed https://registry.npmjs.org/machinepack-urls/-/machinepack-urls-3.1.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
npm ERR! fetch failed https://registry.npmjs.org/escape-regexp/-/escape-regexp-0.0.1.tgz
npm ERR! fetch failed https://registry.npmjs.org/machinepack-urls/-/machinepack-urls-3.1.1.tgz
npm ERR! Linux 3.13.0-63-generic
npm ERR! argv "/home/travis/.nvm/versions/node/v4.4.4/bin/node" "/home/travis/.nvm/versions/node/v4.4.4/bin/npm" "install"
npm ERR! node v4.4.4
npm ERR! npm  v2.15.1
npm ERR! fetch failed with status code 502
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR!     /home/travis/build/practo/consumer-payments-api/npm-debug.log
The command "eval npm install " failed 3 times.
The command "npm install " failed and exited with 1 during .

Please provide the abrupt solution

sails updated the waterline version!!!

Is there have a new version of waterline in this package?

root@iZ234rzua93Z:~/51qf/server# npm ls
npm WARN unmet dependency /alidata1/51quanfan/server/node_modules/sails/node_modules/sails-hook-orm requires waterline@'~0.11.0' but will load
npm WARN unmet dependency /alidata1/51quanfan/server/node_modules/sails/node_modules/waterline,
npm WARN unmet dependency which is version 0.10.19-postman.10

npm ERR! Could not install from "node_modules/sails-mysql-transactions/waterline" as it does not contain a package.json file.

Operating System: iOS
Node version: v9.7.1
NPM version: 5.7.1


The following error occurs when I try installing sails-mysql-transactions by running sudo npm install sails-mysql-transactions --save:


sjca1yshapro:fly-high-training mlgyshan$ sudo npm install sails-mysql-transactions --save
Password:
Unhandled rejection Error: Command failed: /usr/local/bin/git clone --depth=1 -q -b v0.5.1-postman.3 https://github.com/postmanlabs/waterline-sequel.git /Users/mlgyshan/.npm/_cacache/tmp/git-clone-cd22e129
/Users/mlgyshan/.npm/_cacache/tmp/git-clone-cd22e129/.git: Permission denied

    at ChildProcess.exithandler (child_process.js:273:12)
    at ChildProcess.emit (events.js:127:13)
    at maybeClose (internal/child_process.js:936:16)
    at Socket.stream.socket.on (internal/child_process.js:353:11)
    at Socket.emit (events.js:127:13)
    at Pipe._handle.close [as _onclose] (net.js:558:12)


> [email protected] postinstall /Users/mlgyshan/fly-high-training/node_modules/sails-mysql-transactions
> scripts/postinstall.sh

sails-mysql-transactions: Injecting waterline into sails...
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but npm-shrinkwrap.json was generated for lockfileVersion@0. I'll try to do my best with it!
removed 8 packages in 59.246s
npm ERR! code ENOLOCAL
npm ERR! Could not install from "node_modules/sails-mysql-transactions/waterline" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mlgyshan/.npm/_logs/2018-03-13T18_49_48_885Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `scripts/postinstall.sh`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mlgyshan/.npm/_logs/2018-03-13T18_49_49_551Z-debug.log

Here is my log file.

[reflection] [idea]

First of all, this module is awesome; amazing work (particularly the depth you went to w/ making instance methods do their thing when amidst a transaction).

I wanted to leave a note here with some reflections on the history and future of transactions in WL core, and also share an idea for some syntactic sugar based on what I learned from WL2.

Transactions in WL core

Bad news first: We will probably never have true atomic, durable, consistent, and isolated cross-adapter transactions in Waterline core.

Aside: I've always dreamed of having cross-adapter transactions in WL core. I spent a bunch of time messing with this waaaaaay back when I was first building Waterline. In fact, that was almost exactly 3 years ago to the day (Christmas 2012). As it turns out, trying to implement cross-adapter transactions is a nightmare and basically like writing your own database. Nevertheless, for some reason I spent the time to get the "CI" in "ACID" working-- but I never got around to implementing inverse operations in order to be able to roll back-- which we would need to form a truly crash-resistant (read "durable") commit log). Long story short: it is an interesting exercise, but ultimately a bad idea.

The good news is that we will definitely implement transactions across the same connection to the same database. The question is just when-- and you guys have done an amazing job hastening that along.

An idea re: syntax

The #1 thing I've always been worried about w/ transactions is forgetting to rollback under rare error conditions (i.e. that never get tested). The #2 thing has always been forgetting to use the proper transaction instance and accidentally using models directly.

When I was actively working on WL2 last summer, the simplest possible usage I could come up with which also addressed both issues (at least to some degree) was something like this:

orm.transaction([User, Kitten], function (User, Kitten, cb) {
  Kitten.create({ name: req.param('kittenName') }).exec(function (err, babyKitten){
    if (err) {
      return cb(err); // << that means rollback
    }
    User.update({ id: req.session.userId }).set({ petKitten: babyKitten.id }).exec(function (err, updatedUsers) {
      if (err)  {
        return cb(err);  // << that means rollback
      }
      if (updatedUsers.length === 0) {
        err = new Error('Consistency violation: Could no longer find currently logged in user in database!');
        err.code = 'loggedInUserMissingFromDb';
        return cb(err);  // << that means rollback
      }
      return cb(undefined, updatedUsers[0]);  // << that means commit  (so would `cb()`)
      // (second arg is optional, but if you pass it in, it'll show up as the 2nd argument
      //  of the callback below)
    });
  });
}).exec(function (err, data) {
  if (err) {
    // if `err` is truthy, then there was an error, and the transaction was
    // already rolled back by the time we make it here.
    return res.negotiate(err);
  }

  // if not, there were no errors, and the transaction was safely committed
  // by the time we make it here!
  return res.json({
    username: data.username,
    kittenId: data.petKitten
  });
});

Below, I put together a hypothetical remapping of the example in the README of this module if it was wrapped up in something like this (in addition to .start(), not instead of it). Please take it with a grain of salt-- I'm not saying I think it should be this way in this module necessarily (it's more in-line with what we'd need in core Waterline anyway-- i.e. triggering a usage error if the models are not part of the same database connection). I just want to make sure and share this thinking with you guys in case its helpful or spurs any ideas for folding transaction support into Sails/Waterline core.

Here goes nothing:

var Transaction = require('sails-mysql-transactions').Transaction;

// Attempt a database transaction
Transaction.attempt([OneModel, AnotherModel], function (OneModel, AnotherModel, cb) {
  OneModel.create(req.params.all(), function (err, someRecord) {
    if (err) {
      return cb(err);
    }
    AnotherModel.findOne(req.param('id')).exec(function (err, anotherRecord) {
      if (err) {
        return cb(err);
      }
      someRecord.someAssociation.remove(req.param('remove_id'));
      someRecord.save(function (err, savedRecord){
        if (err) {
          return cb(err);
        }
        return cb({
          savedRecord: savedRecord
          anotherRecord: anotherRecord
        });
      });
    });
  });
}).exec(function (err, data) {
  if (err) {
    // This means that either something explicitly passed back an error in the provided function above,
    // or the function never ran because a transaction could not be started, or that the transaction was
    // otherwise successful but could not be committed. If we're here, we know the transaction has
    // been rolled back successfully.
    return res.serverError(err);
  }

  // Otherwise, we know everything worked and that the transaction was committed.
  return res.json({
    one: data.savedModel,
    another: data.anotherInstance
  });
});

Rollback many-to-many (association table) not working with SailsJs 0.12.11

I've tested a simple scenario with two models Dog and Bone (many-to-many association) and I can't get it to rollback.

Here are my two models:

///////////////////
// Dog.js
///////////////////
module.exports = {

  attributes: {

    name: { type: 'string', unique: true },

    age: { type: 'integer' },

    bones: {
      collection: 'bone',
      via: 'dogs'
    }

  }
};

///////////////////
// Bone.js
///////////////////
module.exports = {

    attributes: {

        size: { type: 'string' },
        dogs: {
            collection: 'dog',
            via: 'bones'
        }

    }
};

And here is my test using the framework to try to rollback a modification to the association:

it('should rollback transaction when updating the row with an association table', done => {

            // sails-mysql-transactions
            const Transaction = require('sails-mysql-transactions').Transaction;

            // method to remove all bone associations
            const updateDogBones = (transaction, id) => Dog.transact(transaction).update({ id: id }, { bones: [] });

            // create a dog with 2 bones
            Dog.create({ name: 'fido', age: 1, bones: [{ size: 'small' }, { size: 'large' }] })
                .then(dog => {
                    // start the transaction
                    Transaction.start((err, transaction) => {
                        // remove the bones associations
                        updateDogBones(transaction, dog.id)
                            // fetch back the dog with the transaction
                            .then(() => Dog.transact(transaction).findOne({ id: dog.id }).populate('bones'))
                            .then(dog => {
                                // should have no bones
                                dog.bones.length.should.be.equal(0); // <-- this works
                            })
                            // rollback the transaction
                            .then(() => transaction.rollback(err => {
                                if (err) {
                                    done(err);
                                    return;
                                }
                                // fetch back the dog
                                Dog.findOne({ name: 'fido' })
                                    // populate the dog's bones
                                    .populate('bones')
                                    .then(dog => {
                                        // we should have two here since we rolled back
                                        dog.bones.length.should.be.equal(2); // <-- Error here! we still have 0 after the rollback
                                    })
                                    .then(() => done())
                                    .catch(done);
                            }));
                    });
                });
        });

I've tested both with the Promise and the exec syntax and both are having the same issue.

Here is the output result:

1 failing
  1) SqlTransaction :: beginTransaction :: should rollback transaction when updating the row with an association table:
      AssertionError: expected 0 to equal 2
      + expected - actual
      -0
      +2
      
      at Dog.create.then.Transaction.start.updateDogBones.exec.Dog.transact.findOne.populate.then.then.transaction.rollback.Dog.findOne.populate.then.dog (test\transactions.spec.js:492:72)
      at tryCatcher (node_modules\waterline\node_modules\bluebird\js\release\util.js:11:23)
      at Promise.module.exports.Promise._settlePromiseFromHandler (node_modules\waterline\node_modules\bluebird\js\release\promise.js:491:31)
      at Promise.module.exports.Promise._settlePromise (node_modules\waterline\node_modules\bluebird\js\release\promise.js:548:18)
      at Promise.module.exports.Promise._settlePromise0 (node_modules\waterline\node_modules\bluebird\js\release\promise.js:593:10)
      at Promise.module.exports.Promise._settlePromises (node_modules\waterline\node_modules\bluebird\js\release\promise.js:676:18)
      at Promise.module.exports.Promise._fulfill (node_modules\waterline\node_modules\bluebird\js\release\promise.js:617:18)
      at module.exports (node_modules\waterline\node_modules\bluebird\js\release\nodeback.js:42:21)
      at wrapper (node_modules\waterline\node_modules\lodash\index.js:3592:19)
      at applyInOriginalCtx (node_modules\waterline\lib\waterline\utils\normalize.js:421:80)
      at wrappedCallback (node_modules\waterline\lib\waterline\utils\normalize.js:324:18)
      at success (node_modules\waterline\node_modules\switchback\lib\normalize.js:33:31)
      at _switch (node_modules\waterline\node_modules\switchback\lib\factory.js:58:28)
      at returnResults (node_modules\waterline\lib\waterline\query\finders\basic.js:180:9)
      at node_modules\waterline\lib\waterline\query\finders\basic.js:91:16
      at node_modules\waterline\lib\waterline\query\finders\operations.js:78:46
      at wrapper (node_modules\waterline\node_modules\lodash\index.js:3592:19)
      at applyInOriginalCtx (node_modules\waterline\lib\waterline\utils\normalize.js:421:80)
      at wrappedCallback (node_modules\waterline\lib\waterline\utils\normalize.js:324:18)
      at success (node_modules\waterline\node_modules\switchback\lib\normalize.js:33:31)
      at _switch (node_modules\waterline\node_modules\switchback\lib\factory.js:58:28)
      at node_modules\sails-mysql\lib\connections\spawn.js:114:16
      at Object.poolfully [as releaseConnection] (node_modules\sails-mysql\lib\connections\release.js:28:12)
      at node_modules\sails-mysql\lib\connections\spawn.js:99:35
      at Cursor.attachRecords (node_modules\waterline-cursor\cursor\cursor.js:117:10)
      at afterPopulateBuffers (node_modules\waterline-cursor\cursor\cursor.js:55:10)
      at node_modules\sails-mysql\lib\adapter.js:786:15
      at node_modules\sails-mysql\node_modules\async\lib\async.js:451:17
      at node_modules\sails-mysql\node_modules\async\lib\async.js:441:17
      at _each (node_modules\sails-mysql\node_modules\async\lib\async.js:46:13)
      at Immediate.taskComplete (node_modules\sails-mysql\node_modules\async\lib\async.js:440:13)

UPDATE:
I tested in this repo, I can reproduce the issue with the TeamController.add_member and TeamController.remove_member when changing the commit for a rollback after updating sails from 0.11.5 to 0.12.11

UPDATE 2:

After some research testing with sails 0.12.11, I found out that the issue is not when doing the rollback, but when doing the update using the transaction in my test. The association gets removed right away before commit or rollback. After some testing, I found out that the location of waterline used by Sails has moved from sails' dependencies in node_modules/sails/node_modules/waterline to node_modules/sails-hook-orm/node_modules/waterline so I tried changing the postinstall script to inject waterline at the right place. After doing that, the update/rollback is now working, but I am having a new issue when using the promise syntax or exec syntax vs inline function on the create:

This works just fine:

it('should rollback create', done => {
            const Transaction = require('sails-mysql-transactions').Transaction;
            
            Transaction.start((err, transaction) => {
                Dog.transact(transaction)
                .create({name:'fido'}, (err, dog) => {
                    transaction.rollback(err => {
                        Dog.count({})
                        .then(count => {
                            count.should.be.equal(0);
                            done();
                        });
                    });
                });
            });
        });

This syntax does not not work:

it('should rollback create', done => {
            const Transaction = require('sails-mysql-transactions').Transaction;
            
            Transaction.start((err, transaction) => {
                Dog.transact(transaction)
                .create({name:'fido'})
                .exec((err, dog) => { // <-- This .exec function never gets called
                    transaction.rollback(err => {
                        Dog.count({})
                        .then(count => {
                            count.should.be.equal(0);
                            done();
                        });
                    });
                });
            });
        });

Same thing for this syntax, it doesn't work:

it('should rollback create', done => {
            const Transaction = require('sails-mysql-transactions').Transaction;
            
            Transaction.start((err, transaction) => {
                Dog.transact(transaction)
                .create({name:'fido'})
                .then(dog => { // <-- This .then function never gets called
                    transaction.rollback(err => {
                        Dog.count({})
                        .then(count => {
                            count.should.be.equal(0);
                            done();
                        });
                    });
                });
            });
        });

Model.create() saves the data in the database before using transaction.commit()

Hi all,
I am using the adapter and started a transaction. The transacion creates successfully but when I execute Model.create() it records the data in the database instead of waiting for transaction.commit().
I've even tried to execute a rollback() inmediately after Model.create() with failure.

Do you guys have any clue why is this happening?

PS: This is some pseudo code i am using

Transaction.start(function (err, transaction) {
    return Model1.transact(transaction).create()
        .then(function(result){
            return result;
        })
        .then(function(model1){
            return Model2.transact(transaction).create({'model1_id}': model1.id); //after this, the new Model2 is recorded in the database
        })
        .then(function(new_model2){
            transaction.commit(); //The data is already stored....
            return Model2.findOne({id: new_model2.id}).populate('model1_id');
        })
        .then(function(model2){return model2;})
        .catch(function(err){
            transaction.rollback();
            setTimeout(function(){throw new Error(err);});
        })
}

Add .readonly() support for native queries

First thanks for good library!

I'd like to have ".readonly()" support for native queries, too. In our application we have a lot of complex queries / DB views where data is queried from. Currently we are executing these with sails.models.amodel.query(sql, parameters) ...

It would be very nice to have support for
sails.models.amodel.readonly().query(sql, parameters) so that native queries could use read replicas.

The simplest implementation idea that comes to my mind is to check if query starts with "SELECT". This makes it valid for read replica connection. Otherwise it may be a write clause and it should be sent towards the master DB instance.

Thanks!

SSL Support for connecting to MySQL

Hi,

I'm wondering if sails-mysql-transaction support SSL connection to the database. Using Mysql Client usually SSl connection is made through this command

mysql -h [db url] --ssl-ca=[full path ca cert] --ssl-verify-server-cert -u [username] -p

And I try to set the ssl on the configuration file for sails-mysql-transaction
...
user : db username
password :db password
database: db name
ssl: {
key: null,
cert: null,
ca: fs.readFileSync( full path to CA cert)
}

the connection is failing with the following error:

Encountered an unexpected error: {} Error (E_UNKNOWN) :: Encountered an unexpected error Could not connect to MySQL: Error: unable to verify the first certificate at afterwards (.../node_modules/sails-mysql-transactions/node_modules/sails-mysql/lib/connections/spawn.js:72:13) at .../node_modules/sails-mysql-transactions/node_modules/sails-mysql/lib/connections/spawn.js:40:7 at Handshake.onConnect (.../node_modules/sails-mysql-transactions/node_modules/mysql/lib/Pool.js:54:9) at Handshake.Sequence.end (.../node_modules/sails-mysql-transactions/node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24) at .../node_modules/sails-mysql-transactions/node_modules/mysql/lib/protocol/Protocol.js:169:20 at TLSSocket.<anonymous> (.../node_modules/sails-mysql-transactions/node_modules/mysql/lib/Connection.js:292:7) at TLSSocket.emit (events.js:104:17) at TLSSocket._finishInit (_tls_wrap.js:460:8) Details: Error: Could not connect to MySQL: Error: unable to verify the first certificate

Any ideas? Thanks a lot.

Transactions vs User balance

What is the best idea to use the "sails-mysql-transactions" to add or remove value of a column? I want to remove balance / add.

I'm making a purchase / sale module.

Sails-mysql-transactions installation fails in postinstall stage

NPM error while running the postinstall script.

Details:
my-pc$ npm i sails && npm i sails-mysql-transactions
npm WARN gentlyRm not removing /Users/annuay/Kapitalwise/sailsmysqltesting/versions_of_code/kw_web_services_version_3/node_modules/sails/node_modules/.bin/grunt as it wasn't installed by /Users/annuay/Kapitalwise/sailsmysqltesting/versions_of_code/kw_web_services_version_3/node_modules/sails/node_modules/grunt-cli

[email protected] preinstall /Users/annuay/Kapitalwise/sailsmysqltesting/versions_of_code/kw_web_services_version_3/node_modules/sails
node ./lib/preinstall_npmcheck.js

Sails.js Installation: Checking npm-version successful

[email protected] preinstall /Users/annuay/Kapitalwise/sailsmysqltesting/versions_of_code/kw_web_services_version_3/node_modules/sails-mysql-transactions/node_modules/newman
node ./scripts/preinstall.js


  •                       Notice                               *
    

  • If you are using Node v0.12 or v0.10, you should install *
  • Newman v1.x: *
  •                                                            *
    
  •               npm install newman@1                         *
    
  •                                                            *
    
  • Deprecation: Newman v3 onwards will deprecate the use of DOM *
  • related libraries, such as JQuery and Backbone. For details, *
  • check https://www.getpostman.com/docs/sandbox *

[email protected] postinstall /Users/annuay/Kapitalwise/sailsmysqltesting/versions_of_code/kw_web_services_version_3/node_modules/sails-mysql-transactions
scripts/postinstall.sh

sails-mysql-transactions: WARNING - detected sails-mysql.
sails-mysql-transactions: You may face unexpected behaviour.
sails-mysql-transactions: Preferably remove sails-mysql from packages before using this in production.

sails-mysql-transactions: Injecting waterline into sails...
npm WARN deprecated [email protected]: Use uuid module instead
npm WARN deprecated [email protected]: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
npm WARN deprecated [email protected]: This module is now under the @mapbox namespace: install @mapbox/geojsonhint instead
npm WARN deprecated [email protected]: 'native-or-bluebird' is deprecated. Please use 'any-promise' instead.
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

[email protected] preinstall /Users/annuay/Kapitalwise/sailsmysqltesting/versions_of_code/kw_web_services_version_3/node_modules/sails/node_modules/extendr/node_modules/typechecker
node ./cyclic.js

[email protected] preinstall /Users/annuay/Kapitalwise/sailsmysqltesting/versions_of_code/kw_web_services_version_3/node_modules/sails/node_modules/extract-opts/node_modules/typechecker
node ./cyclic.js

npm WARN prefer global [email protected] should be installed with -g
npm notice created a lockfile as package-lock.json. You should commit this file.
added 752 packages, removed 1 package and updated 1 package in 99.333s
npm WARN checkPermissions Missing write access to /Users/annuay/Kapitalwise/sailsmysqltesting/versions_of_code/kw_web_services_version_3/node_modules/sails-mysql-transactions/waterline/node_modules/async
npm WARN checkPermissions Missing write access to /Users/annuay/Kapitalwise/sailsmysqltesting/versions_of_code/kw_web_services_version_3/node_modules/sails-mysql-transactions/waterline/node_modules/bluebird
npm WARN checkPermissions Missing write access to /Users/annuay/Kapitalwise/sailsmysqltesting/versions_of_code/kw_web_services_version_3/node_modules/sails-mysql-transactions/waterline/node_modules
npm ERR! path /Users/annuay/Kapitalwise/sailsmysqltesting/versions_of_code/kw_web_services_version_3/node_modules/sails-mysql-transactions/waterline/node_modules/async
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access '/Users/annuay/Kapitalwise/sailsmysqltesting/versions_of_code/kw_web_services_version_3/node_modules/sails-mysql-transactions/waterline/node_modules/async'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/annuay/.npm/_logs/2017-06-07T14_22_18_390Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 254
npm ERR! [email protected] postinstall: scripts/postinstall.sh
npm ERR! Exit status 254
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/annuay/.npm/_logs/2017-06-07T14_22_34_986Z-debug.log

Transaction Integrity

Hello again buddy, I have another question(Yes, is a technical question, not a problem).

How do I know if a transaction works correctly? How do I know if the data is not duplicated if two people simultaneously do on purpose the same request? Supposedly the first request to enter the queue, it has to be processed and the following have to give some kind of mistake, right?

Imagine that two people are trying to make a purchase of a single item on my website, how can I write this code?

Here are an example:

`
var uid = req.session.user.id;

Item.findOne(itemID)
.exec(function(err, ItemEntity) {

    if(err)
        return res.serverError(err);

    if(!ItemEntity)
        return res.serverError(err);

    // Check and get my balance...
    var balance = ...;

    // Send items to my backpack
    UserItems.create({
        uid: uid,
        itemID: ItemEntity.id
    })
    .exec(function(err) {

        if(err)
            return res.serverError(err);

        ItemEntity.destroy(function() {

            return res.ok({data:success});
        });
    });
});

`

How do I know an item to only one user has been added?

Transactions not working

Sometimes the field "transactionId" is not injected in the tables and the transactions do not work. I wonder why.
Thank you.

sails-mysql-transactions issues while integerating

I am trying to install sails-mysql-transactions. I have uninstalled sails-mysql added sails-mysql-transactions to postscript, already having sails 0.11.4 installed, then also i am not able to install the adapter. Gives an error when i do npm install ,
[email protected]~postinstall: cannot run in wd %s %s (wd=%s) [email protected] npm install sails-mysql-transactions /home/vagrant/www/test-app

  • serve-static node_modules/sails/node_modules/serve-static

Error while trying to use Model.stream

While doing MyModel.stream({user: user_id}).pipe(theSocket>); this module throws an error. I'm trying to stream waterline models as discussed here. Trace below:

TypeError: sql.selectQuery is not a function
    at __STREAM__ (node_modules/sails-mysql-transactions/sails-mysql/lib/adapter.js:905:25)
    at afterwards (node_modules/sails-mysql-transactions/sails-mysql/lib/connections/spawn.js:84:5)
    at node_modules/sails-mysql-transactions/sails-mysql/lib/connections/spawn.js:40:7
    at Handshake.onConnect (node_modules/mysql/lib/Pool.js:59:7)
    at Handshake.Sequence.end (node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24)
    at Handshake.Sequence.OkPacket (node_modules/mysql/lib/protocol/sequences/Sequence.js:105:8)
    at Protocol._parsePacket (node_modules/mysql/lib/protocol/Protocol.js:271:23)
    at Parser.write (node_modules/mysql/lib/protocol/Parser.js:77:12)
    at Protocol.write (node_modules/mysql/lib/protocol/Protocol.js:39:16)
    at Socket.<anonymous> (node_modules/mysql/lib/Connection.js:92:28)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at TCP.onread (net.js:548:20)

Entity not found on executing findOne within transaction

Here are sequence of steps involved which result in the issue.

  1. Save entity using .create() within a transaction
  2. Retrieve entity using .findOne() within the same transaction with the id of the entity from step 1
  3. The result of step 2 is an undefined entity

Am I doing something wrong here?

Feature Request: Support for connectionLifetime option

The idea is to destroy a connection from a pool once it has stayed connected for a specified duration of time.

  • we need to accept this option
  • we need to listen to the connection event in pool and set the current time in it
  • listen to the release event of pool and check if current time is - created time is > lifetime option.
  • if yes to above, then do connection.destroy()

Ref:
mysqljs/mysql#1872 (API to destroy)
https://github.com/mysqljs/mysql#pool-events (Pool Events)
https://github.com/postmanlabs/sails-mysql-transactions/blob/develop/lib/db.js (module where the read-only pool cluster is created)
https://github.com/postmanlabs/sails-mysql/tree/master-postman/lib/connections (location where writeable pools are created)

console log queries

hello everyone,
I want to log every query when I use sails normal model methods(such as: Model.create(),Model.update). Can I just setup some config for 'sails-mysql-transactions' to implement this? I really need this. Anyone can help me ?

Remove transactionId from results

If I do the following:

Model.find().exec(function(err, data){
    return data;
});

The array contains objects and one of the values in the object is transactionId. Currently I'm looping through the data and deleting that field.

Installation failure

Hi, when I tried to remove sails-mysql and install sails-mysql-transactions, something wrong happened. I really want to use the transaction but sails-mysql only provide the raw query. I wonder whether someone else also met this problem. My operating system is ubuntu 14.04 LTS. The error is as follows:

> [email protected] postinstall /home/davidlee/Desktop/test-memo/node_modules/sails-mysql-transactions
> scripts/postinstall.sh

sails-mysql-transactions: Injecting waterline...
unbuild [email protected]
npm ERR! Linux 3.19.0-32-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "remove" "waterline"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! path /usr/local/lib/node_modules/sails/node_modules/waterline
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, rmdir '/usr/local/lib/node_modules/sails/node_modules/waterline'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, rmdir '/usr/local/lib/node_modules/sails/node_modules/waterline']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/sails/node_modules/waterline' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Linux 3.19.0-32-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "remove" "waterline"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! path npm-debug.log.45b160efe928ba4be309777a88687306
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, open 'npm-debug.log.45b160efe928ba4be309777a88687306'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, open 'npm-debug.log.45b160efe928ba4be309777a88687306']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: 'npm-debug.log.45b160efe928ba4be309777a88687306' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /usr/local/lib/node_modules/sails/npm-debug.log
npm ERR! Linux 3.19.0-32-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "sails-mysql-transactions" "--save"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: `scripts/postinstall.sh`
npm ERR! Exit status 243
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script 'scripts/postinstall.sh'.
npm ERR! This is most likely a problem with the sails-mysql-transactions package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     scripts/postinstall.sh
npm ERR! You can get their info via:
npm ERR!     npm owner ls sails-mysql-transactions
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/davidlee/Desktop/test-memo/npm-debug.log

Thank you very much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.