Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lux-framework

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lux-framework - npm Package Versions

134

1.1.1

Diff

Changelog

Source

v1.1.1 (Dec 28, 2016)

Commits
zacharygolba
published 1.1.0 •

Changelog

Source

1.1.0 (Dec 10, 2016)

Features
Transactions

This release introduces a public transaction api to the model class. Changes are backwards compatible with the previous model api.

Internally, all methods that modify the state of the database are wrapped in transactions. If the transaction fails, all calls to create, save, or update will be rolled back to the state before the transaction began.

Example:

import User from 'app/models/user';

// This internally uses a transaction.
await User.create({
  firstName: 'New',
  lastName: 'User'
});

Working With Transactions

You have the ability to manually specify the transaction that will be used for a create, update, or save call with the static and instance method, transacting.

Example:

import { Model } from 'lux-framework';

import Profile from 'app/models/profile';

class User extends Model {
  static hasOne = {
    profile: {
      inverse: 'user'
    }
  };

  static hooks = {
    async beforeCreate(user, trx) {
      // If the transaction fails the profile instance will not be persisted.
      user.profile = await Profile
        .transacting(trx)
        .create();
    }
  };
}

You can also manually trigger create a transaction if you plan on creating many model instances as once.

Example:

import User from 'app/models/user';

User.transaction(trx => (
  Promise.all([
    User
      .transacting(trx)
      .create({
        firstName: 'New',
        lastName: 'User'
      }),
    User
      .transacting(trx)
      .create({
        firstName: 'New',
        lastName: 'User'
      }),
    User
      .transacting(trx)
      .create({
        firstName: 'New',
        lastName: 'User'
      })
  ])
));
Commits
  • [3f15362600] - deps: update babel-core to version 6.20.0 (#556) (Greenkeeper)
  • [9a20c5ce11] - deps: update eslint to version 3.12.0 (#557) (Greenkeeper)
  • [7f53cd230c] - docs: fix broken logo in readme (#555) (Zachary Golba)
  • [590956ed52] - docs: add preliminary guide files (#554) (Zachary Golba)
  • [16d224b4e7] - feat: use transactions when writing to the database (#527) (Zachary Golba)
  • [9e89b042cd] - deps: update eslint-plugin-flowtype to version 2.29.1 (#549) (Greenkeeper)
  • [5b3e91e5f9] - deps: update eslint to version 3.11.1 (#547) (Greenkeeper)
  • [4eb0c9b926] - deps: update eslint-plugin-flowtype to version 2.28.2 (#546) (Greenkeeper)
  • [42f1707ac8] - deps: update eslint to version 3.11.0 🚀 (#539) (Greenkeeper)
  • [39adf76c3a] - deps: update rollup to version 0.36.4 (#536) (Greenkeeper)
  • [23189f535b] - deps: update flow-bin to version 0.36.0 🚀 (#537) (Greenkeeper)
  • [394d3132e7] - deps: update nyc to version 10.0.0 (#535) (Greenkeeper)
  • [ef33526860] - deps: update mocha to version 3.2.0 (#538) (Greenkeeper)
  • [760ae5f68c] - release: 1.0.5 🔧 (#534) (Zachary Golba)
zacharygolba
published 1.0.5 •

Changelog

Source

1.0.5 (Nov 20, 2016)

Commits
  • [45c18600c4] - deps: update babel-eslint to version 7.1.1 (#533) (Greenkeeper)
  • [0720dda77f] - deps: update eslint to version 3.10.2 (#532) (Greenkeeper)
  • [dbdcc5a2de] - fix: query parameters are not added to custom routes (#528) (Nick Schot)
  • [4530d0ce8d] - deps: update nyc to version 9.0.1 (#530) (Greenkeeper)
  • [8d36091058] - deps: update eslint to version 3.10.1 (#529) (Greenkeeper)
  • [c586f350f6] - docs: use master branch for appveyor badge (#526) (Zachary Golba)
  • [e93b45ca4b] - deps: update test-app dependencies (#525) (Zachary Golba)
  • [0bbb7af65c] - release: 1.0.4 🔧 (#524) (Zachary Golba)
zacharygolba
published 1.0.4 •

Changelog

Source

1.0.4 (Nov 12, 2016)

Commits
  • [7d2ff0d316] - fix: ids in json payloads should be cast to number (#523) (Zachary Golba)
  • [8cca55e756] - fix: empty 1:1 relationships are not returned in correct format (#521) (Zachary Golba)
  • [6919517b37] - test: prevent ci builds from failing due to time constraints (#520) (Zachary Golba)
  • [090f871f18] - fix: passing value null in post to type number throws type error (#516) (Zachary Golba)
  • [6cd3e68b6e] - deps: update flow-bin to version 0.35.0 🚀 (#517) (Greenkeeper)
  • [cd4f63fe4a] - deps: update eslint to version 3.10.0 (#518) (Greenkeeper)
  • [b97d093c9a] - fix: default values override all falsy attribute values (#515) (Zachary Golba)
  • [6f4e17078c] - dx: use flow-typed instead of custom type declarations when possible (#514) (Zachary Golba)
  • [44b88250a2] - docs: use shields.io for project status badges in readme (#513) (Zachary Golba)
  • [2e9c3353b1] - release: 1.0.3 🔧 (#512) (Zachary Golba)
zacharygolba
published 1.0.3 •

Changelog

Source

1.0.3 (Nov 10, 2016)

Commits
  • [53378f622b] - fix: dynamic segments are not parsed on model-less resources (#510) (Zachary Golba)
  • [56321bb7df] - fix: small typos in model initialize-class.js (#505) (Nick Schot)
  • [7769865731] - chore: use codecov bash uploader (#511) (Zachary Golba)
  • [edb4635b8c] - fix: some strings in request body cast to another type (#506) (Zachary Golba)
  • [dea08354ab] - deps: update eslint-config-airbnb-base to version 10.0.1 🚀 (#503) (Greenkeeper)
  • [b7435570fc] - deps: update eslint-plugin-import to version 2.2.0 (#504) (Greenkeeper)
  • [18ba638610] - deps: update babel-plugin-transform-es2015-modules-commonjs to version 6.18.0 (#500) (Zachary Golba)
  • [59a16f19ca] - deps: update eslint to version 3.9.1 (#501) (Zachary Golba)
  • [e12eb406d2] - deps: update eslint-plugin-import to version 2.1.0 (#498) (Greenkeeper)
  • [7b1c48b4aa] - deps: update eslint to version 3.9.0 🚀 (#489) (Greenkeeper)
  • [61c37cc4de] - deps: update source-map-support to version 0.4.6 (#492) (Greenkeeper)
  • [055bf5f5fe] - deps: update babel-core to version 6.18.2 (#496) (Greenkeeper)
  • [63db399c8c] - deps: update nyc to version 8.4.0 (#497) (Greenkeeper)
  • [26ba4e5a21] - deps: update remark-lint to version 5.2.0 (#494) (Greenkeeper)
  • [46f223b77f] - deps: update flow-bin to version 0.34.0 (#490) (Greenkeeper)
  • [71214e17ff] - deps: update remark-cli to version 2.1.0 (#488) (Greenkeeper)
  • [748b26b577] - deps: update babel-eslint to version 7.1.0 (#487) (Greenkeeper)
  • [d98139e08c] - deps: update eslint-plugin-flowtype to version 2.25.0 (#486) (Greenkeeper)
  • [40bea0b2d1] - deps: update eslint-plugin-flowtype to version 2.24.0 (#485) (Greenkeeper)
  • [edaec79e12] - deps: update babel-core to version 6.18.0 (#483) (Greenkeeper)
  • [ce25efdad7] - deps: update eslint-plugin-flowtype to version 2.23.1 (#484) (Greenkeeper)
  • [be7fef2034] - deps: update eslint-plugin-flowtype to version 2.22.0 (#481) (Greenkeeper)
  • [3e578257f9] - release: 1.0.2 🔧 (#480) (Zachary Golba)
zacharygolba
published 1.0.2 •

Changelog

Source

1.0.2 (Oct 24, 2016)

Commits
  • [bbf68000ea] - fix: controllers are not properly resolving for resources with custom paths (#478) (Zachary Golba)
  • [1a52cc1cec] - deps: update eslint-plugin-flowtype to version 2.21.0 (#479) (Greenkeeper)
  • [fe35b45935] - release: 1.0.1 🔧 (#477) (Zachary Golba)
zacharygolba
published 1.0.1 •

Changelog

Source

1.0.1 (Oct 20, 2016)

Commits
  • [f27eab4e66] - fix: readdir error is causing cli commands to fail (#476) (Zachary Golba)
  • [2deea84ab9] - release: 1.0.0 🎉 (#472) (Zachary Golba)
zacharygolba
published 1.0.0 •

Changelog

Source

1.0.0 (Oct 20, 2016)

Commits
  • [34d9478323] - deps: update test-app dependencies (#475) (Zachary Golba)
  • [71dc913fb8] - chore: add markdown linter (#474) (Zachary Golba)
  • [0f1aa9fe69] - deps: update nyc to version 8.3.2 (#473) (Greenkeeper)
  • [0ca4477935] - docs: fix link to guides in readme (#471) (Chris Watts)
  • [ea471aad7f] - fix: eslint config in compiler inherits from lux .eslintrc.json (#469) (Zachary Golba)
  • [2c74a0cc9c] - docs: add logo to readme (#470) (Zachary Golba)
  • [6656b9aca5] - docs: finalize public api docs for 1.0 release (#418) (Zachary Golba)
  • [7af75be54f] - deps: update source-map-support to version 0.4.5 (#468) (Greenkeeper)
  • [362b196db3] - deps: update eslint to version 3.8.1 (#467) (Greenkeeper)
  • [d8833a9968] - deps: update eslint-config-airbnb-base to version 9.0.0 🚀 (#464) (Greenkeeper)
  • [e0cde3bc20] - deps: update babel-plugin-istanbul to version 2.0.3 (#465) (Greenkeeper)
  • [0b9b017a26] - test: improve logger test coverage (#452) (Zachary Golba)
  • [a343f87273] - refactor: ensure tableName is statically evaluated (#462) (Zachary Golba)
  • [fd60ff7b77] - deps: update source-map-support to version 0.4.4 (#463) (Greenkeeper)
  • [b86a4cbe3d] - deps: update test-app dependencies (#461) (Zachary Golba)
  • [54db513fa3] - feat: expose controller and action in public request api (#460) (Zachary Golba)
  • [e289ffc142] - feat: add after-action middleware hook to controller (#459) (Zachary Golba)
  • [b74b52ff75] - deps: update mocha to version 3.1.2 (#458) (Zachary Golba)
  • [c14625a38c] - deps: update eslint to version 3.8.0 🚀 (#457) (Greenkeeper)
  • [0a6c953345] - fix: namespaced resources without root controllers/serializers is not… (#454) (Zachary Golba)
  • [a2bee41294] - fix: compiler does not properly format class names for nested namespaces (#449) (Zachary Golba)
  • [adc723040c] - deps: update eslint-plugin-import to version 2.0.1 (#451) (Greenkeeper)
  • [c8995a2f75] - test: add unit tests for route definitions (#443) (Zachary Golba)
  • [ec18b7ac96] - deps: update mocha to version 3.1.1 (#448) (Greenkeeper)
  • [f6a868bd77] - deps: update rollup to version 0.36.3 (#447) (Greenkeeper)
  • [3dfc2907e2] - fix: remove unused plugins in lib/babel-hook (#444) (Zachary Golba)
  • [e7316c0df3] - fix: use path.sep to resolve root tmp dirs in fs tests (#442) (Zachary Golba)
  • [345e8c6b73] - test: add unit tests for controller utils (#441) (Zachary Golba)
  • [a4d9952984] - refactor: make watcher a child of the fs package (#412) (Zachary Golba)
  • [20480fa1c9] - deps: update test-app dependencies (#440) (Zachary Golba)
  • [b3445ce5a4] - deps: update nyc to version 8.3.1 (#439) (Greenkeeper)
  • [1bfd98e77a] - test: run flow on appveyor builds (#432) (Zachary Golba)
  • [9e2f84bd2d] - refactor: use airbnb eslint rules (#434) (Zachary Golba)
  • [57101cfaf1] - deps: update eslint-plugin-flowtype to version 2.20.0 (#438) (Greenkeeper)
  • [bf213b49b8] - deps: update eslint to version 3.7.1 (#437) (Zachary Golba)
  • [84b7bd0d14] - deps: update babel-preset-lux to version 1.3.0 (#436) (Greenkeeper)
  • [eaeb9eb983] - test: enable parallel circleci builds (#435) (Zachary Golba)
  • [c8f05ee180] - deps: update babel-core to version 6.17.0 (#433) (Greenkeeper)
  • [856aeae646] - test: switch to circleci (#431) (Zachary Golba)
  • [0a49d14f1e] - deps: update source-map-support to version 0.4.3 (#428) (Greenkeeper)
  • [339c35c864] - deps: update babel-core to version 6.16.0 (#427) (Zachary Golba)
  • [c3483ac1dc] - chore(package): update babel-core to version 6.16.0 (greenkeeperio-bot)
  • [17780a1c6c] - deps: update babel-plugin-transform-es2015-modules-commonjs to version 6.16.0 (#430) (Greenkeeper)
  • [fd7bbe2f90] - deps: update flow-bin to version 0.33.0 🚀 (#429) (Greenkeeper)
  • [d3c67a51c8] - deps: update rollup to version 0.36.1 (#426) (Greenkeeper)
  • [de8c3f16bb] - chore: change ecmaVersion to 2017 in .eslintrc.json (#425) (Zachary Golba)
  • [32064c964e] - deps: update babel-eslint to version 7.0.0 (#424) (Greenkeeper)
  • [5fb4a42192] - deps: update mocha to version 3.1.0 (#423) (Greenkeeper)
  • [c7fe135343] - deps: update eslint to version 3.6.1 (#422) (Greenkeeper)
  • [0e6ec39138] - refactor: cleanup unecessary controller props (#420) (Zachary Golba)
  • [a12bcad4c9] - deps: update node-fetch to version 1.6.3 (#421) (Zachary Golba)
  • [85fc7fc82f] - chore(package): update node-fetch to version 1.6.3 (greenkeeperio-bot)
  • [28b03d63f7] - docs: update examples (#419) (Zachary Golba)
  • [6b2f86da48] - deps: update sinon to version 1.17.6 (#416) (Zachary Golba)
  • [15c5ca0c0c] - deps: update node-fetch to version 1.6.2 (#415) (Greenkeeper)
  • [aa81af568c] - deps: update eslint to version 3.6.0 (#414) (Greenkeeper)
  • [f0d660c599] - fix: application keys being overwritten (#411) (Zachary Golba)
  • [585584d2f7] - test: improve luxify test coverage (#409) (Zachary Golba)
  • [73579fb570] - test: add unit tests for route namespaces (#410) (Zachary Golba)
  • [29dab32f86] - test: refactor serializer tests to improve coverage (#408) (Zachary Golba)
  • [999f64933c] - deps: update mysql2 to v1.1.0 in test-app (#413) (Zachary Golba)
  • [233d4a716c] - test: add unit tests for relationships module in database package (#407) (Zachary Golba)
  • [ade16b5d5e] - deps: update eslint-plugin-flowtype to version 2.19.0 (#406) (Greenkeeper)
  • [a11ee86f27] - deps: update rollup to version 0.36.0 (Greenkeeper)
  • [4d35d593bf] - test: improve overall test coverage (#287) (Zachary Golba)
  • [cd1e822817] - deps: update eslint-plugin-flowtype to version 2.18.2 (#397) (Greenkeeper)
  • [bf5571db8f] - deps: update test-app dependencies (#395) (Zachary Golba)
  • [007fd125ae] - deps: update eslint-plugin-flowtype to version 2.18.1 (#389) (Greenkeeper)
  • [b0bb089ae3] - deps: update eslint-plugin-flowtype to version 2.17.1 (#387) (Greenkeeper)
  • [d1e42c47f4] - chore: switch to bcryptjs instead of native bcrypt in social-network example (#383) (Zachary Golba)
  • [e4966fd1f7] - chore: fix authentication in social-network example (#378) (Zachary Golba)
  • [bbbe317a44] - deps: update eslint to version 3.5.0 (#373) (Greenkeeper)
  • [271722efd2] - deps: update eslint-plugin-flowtype to version 2.16.1 (#372) (Greenkeeper)
  • [7a3b836d51] - deps: update rollup-plugin-eslint to version 3.0.0 (#370) (Greenkeeper)
  • [c823ce4da2] - chore: use bcrypt in social network example (#371) (Adrien Montfort)
  • [bc7eba0e44] - deps: update eslint-plugin-flowtype to version 2.16.0 (#369) (Greenkeeper)
  • [15e21ec3bf] - deps: update rollup-plugin-json to version 2.0.2 (#368) (Greenkeeper)
  • [9f1e3ef7db] - deps: update eslint-plugin-flowtype to version 2.15.0 (#367) (Greenkeeper)
  • [38081786f6] - deps: update eslint-plugin-flowtype to version 2.14.3 (#366) (Greenkeeper)
  • [77b623a257] - release: 1.0.0-rc.7 (#363) (Zachary Golba)
zacharygolba
published 1.0.0-rc.7 •

Changelog

Source

1.0.0-rc.7 (Sept 4, 2016)

This release implements a fix for a regression in 1.0.0-rc.6 where model migrations would include the formatted filename as the table name (i.e '2016050414243335_create_posts' instead of 'posts').

Commits
  • [7bd0f4d87b] - chore: update example applications (#361) (Zachary Golba)
  • [9bcecc5650] - release: 1.0.0-rc.6 (#360) (Zachary Golba)
zacharygolba
published 1.0.0-rc.6 •

Changelog

Source

1.0.0-rc.6 (Sept 4, 2016)

This release contains a number of bug fixes related to overriding default behavior such as custom actions, model-less controllers, etc. In addition to bug fixes this release contains some awesome new features.

Upgrading

Route definitions have changed quite a bit with the implementation of router namespaces. In order to upgrade you will have to remove any calls to this.route within the app/routes.js file.

Previously, this.route was a means of defining custom routes or just defining individual routes rather than a whole resource. It did not scale well to multiple namespaces and was kind of a clunky API to begin with.

To define a custom route within a resource you may do the following:

export default function routes() {
  // Arbitrary Routes (i.e /{route})
  // GET /health => ApplicationController#health
  this.get('health');

  this.resource('posts', function () {
    // Member Routes (i.e /posts/:id/{route})
    this.member(function () {
      // GET /posts/1/comments => PostsController#comments()
      this.get('comments');

      // POST /posts/1/comments => PostsController#createComment()
      this.post('comments', 'createComment');
    });

    // Collection Routes (i.e /posts/{route})
    this.collection(function () {
      // GET /posts/drafts => PostsController#drafts()
      this.get('drafts');
    });
  });
}

To only define a subset of routes for a given resource you may now do the following as shortcut:

export default function routes() {
  // GET /posts => 200 OK
  // GET /posts/1 => 200 OK
  // POST /posts => 404 Not Found
  // PATCH /posts/1 => 404 Not Found
  // DELETE /posts/1 => 404 Not Found
  this.resource('posts', {
    only: ['show', 'index']
  });
}
Features
Router Namespaces

You now have the ability to define namespaces with your routes. Common uses cases for defining a namespace within your routes include admin-only routes, requiring payment from a user, api versioning, etc.

Generators

To generate a resource within a namespace, include the namespace as part of the name argument passed to the generate command.

Example:

lux generate resource admin/posts

The command above will result in the following files being created:

  • app/controllers/admin/posts
  • app/serializers/admin/posts

If you do not already have an ApplicationController or ApplicationSerializer for a namespace, they will automatically be generated.

Also, the generate command will omit namespaces when generating a Model or Migration. If you generate a resource in a namespace that already has a Model, you will be given the choice to either overwrite or skip the Model or Migration files.

Controllers

You can think of a namespace as if it is it's own Lux application that you are mounting into it's parent namespace. Similar to how a Controller works in previous versions, a Controller within a namespace will merge it's middleware with the ApplicationController for the namespace it is a part of. If the Controller is the ApplicationController for a namespace, it will merge it's middleware with the ApplicationController of parent namespace if possible.

Example:

/*********************
 * Namespace: 'Root' *
 * Path: '/'         *
 *********************/

import { Controller } from 'lux-framework';

class ApplicationController extends Controller {
  beforeAction = [
    async function sayHello({ logger }) {
      logger.info('Hello world!');
    }
  ];
}

class PostsController extends Controller {
  index() {
    return Post.isPublic();
  }
}

A GET request to /posts will result in the following functions (in this order) handling the request:

  • sayHello
  • PostsController#index

The PostsController#index action only gives us the posts that are publicly available. This is what we want, but we should have a way for user's with admin access to be able to see what has not been published yet. To accomplish this we will use a namespace.

/**********************
 * Namespace: 'admin' *
 * Path: '/admin'     *
 **********************/

import { Controller } from 'lux-framework';

class AdminApplicationController extends Controller {
  beforeAction = [
    async function authenticate() {
      // Authenticate request...
    }
  ];
}

class AdminPostsController extends Controller {
  index() {
    return Post.all();
  }
}

A GET request to /admin/posts will result in the following functions (in this order) handling the request:

  • sayHello
  • authenticate
  • AdminPostsController#index

As you can see in the example above, namespaces allow you to isolate middleware functions in a beforeAction array to only execute at certain paths of your application. This is done behind the scenes with Lux and does not require you to use inheritance between your controllers. Inheritance is 100% opt-in so feel free to start from scratch while still gaining the benefit of shared middleware functions.

Sometimes it can be nice to use inheritance if we're only slightly changing the behavior of a Controller. Let's look at an example where the AdminPostsController extends the PostsController.

import PostsController from 'app/controllers/posts';

class AdminPostsController extends PostsController {
  index(request, response) {
    return super.index(request, response).unscope('isPublic');
  }
}

In the example above we are able to simply remove the isPublic scope from the #index() action because we are using inheritance. This would be very helpful if we added additional logic to the #index() route that would have otherwise had to duplicate across posts routes in other namespaces.

Keep in mind, inheritance can be an anti-pattern if it takes you more work to override methods than it would be to start fresh.

Serializers

Serializers within a namespace work very similar to a Controller. The main difference being that it is not required to have a Serializer within each namespace. Serializers will resolve to their closest ancestor. That means that if you have a PostsSerializer for a posts resource at the root namespace, requests to /admin/posts will fall back to use the PostsSerializer if a AdminPostsSerializer is not found at app/serializers/admin/posts.js.

Serializers within a namespace are great for versioning an api. Over time some fields may become deprecated in your responses and using serializers in a namespace is a great way to solve this problem.

Example:

/**********************
 * Namespace: 'v1' *
 * Path: '/v1'     *
 **********************/
import { Serializer } from 'lux-framework';

class V1PostsSerializer extends Serializer {
  attributes = [
    'body',
    'title',
    'deprecated'
  ];

  hasOne = [
    'author'
  ];

  haMany = [
    'comments'
  ];
}

As you can see above we have a V1PostsSerializer that has an attribute that we no longer wish to include in responses in the v2 namespace. We can use a namespaces to help us accomplish this task.

/**********************
 * Namespace: 'v2' *
 * Path: '/v2'     *
 **********************/

import V1PostsSerializer from 'app/serializers/v1/posts';

 class V2PostsSerializer extends V1PostsSerializer {
   attributes = [
     'body',
     'title'
   ];
 }

🎉 It's that simple. Requests to /v1/posts will include the deprecated attribute while requests to /v2/posts will not.

Defining Namespaces

To define a namespace in your application, you must specify it in the app/routes.js file.

function routes() {
  this.resource('posts');

  this.namespace('admin', function () {
    this.resource('posts');
  });
}

There is no limit to how many levels you nest namespaces. Lux will flatten the execution of functions nested within namespaces during application boot so feel free to go crazy.

function routes() {
  this.namespace('a', function () {
    this.resource('posts');

    this.namespace('b', function () {
      this.resource('posts');

      this.namespace('c', function () {
        this.resource('posts');

        this.namespace('d', function () {
          this.resource('posts');
        });
      });
    });
  });
}
Persistence Checking

Previously, the only means of checking persistence was by checking if a Model has an dirty attributes. This was unsuitable for determining wether or not a record has been persisted to the database yet.

We have added Model#isNew and Model#persisted to handle this.

Example:

import Post from 'app/models/posts';

let post = await Post.first();


/**
 * Check existing record's persistence...
 */
post.isDirty
// => false
post.isNew
// => false
post.persisted
// => true


/**
 * Check an existing record's persistence after an attribute has been changed...
 */
post.title = 'add ability to check if model has been saved';
// => 'add ability to check if model has been saved'
post.isDirty
// => true
post.isNew
// => false
post.persisted
// => false


await post.save();

/**
 * Check a recently saved record's persistence...
 */
post.isDirty
// => false
post.isNew
// => false
post.persisted
// => true


post = new Post({
  title: 'I have yet to be saved.'
});

/**
 * Check the persistence of a record that has yet to be saved...
 */
post.isDirty
// => false
post.isNew
// => true
post.persisted
// => false


/**
 * Check a new record that was created via the #create() method...
 */
post = await Post.create({
  title: 'I have yet to be saved.'
});

post.isDirty
// => false
post.isNew
// => false
post.persisted
// => true
Distinct Queries

🎉 You can now do distinct queries on a Model.

import Post from 'app/models/post';

Post.distinct('title' /*, 'body', ...etc */).where({
  isPublic: true
});

// SELECT DISTINCT "posts"."title" AS "title" FROM "posts" WHERE "posts"."is_public" = TRUE
Commits
  • [361acd467f] - deps: update babel-preset-lux to version 1.2.0 (#359) (Greenkeeper)
  • [1adeb907df] - feat: router namespaces (#338) (Zachary Golba)
  • [1f9094e5db] - chore: add appveyor badge to readme (#358) (Zachary Golba)
  • [af75c59062] - chore: remove unnecessary event emitter decl (#357) (Zachary Golba)
  • [ce5568297d] - deps: update flow-bin to version 0.32.0 🚀 (#356) (Greenkeeper)
  • [48d1cf8cd9] - chore: improve ci set up (#350) (Zachary Golba)
  • [58a4c6ed04] - deps: update rollup to version 0.34.13 (#355) (Greenkeeper)
  • [603c45a5ec] - deps: update rollup to version 0.34.11 (#353) (Greenkeeper)
  • [0e05e3d9b9] - fix: lux console fails when running on an npm linked version of the master branch (#349) (Zachary Golba)
  • [5d492f5cea] - feat: add #distinct() query method (#346) (Zachary Golba)
  • [d9e00625e6] - feat: add ability to check if model has been saved (#347) (Zachary Golba)
  • [6474d516b5] - deps: update eslint to version 3.4.0 (#345) (Greenkeeper)
  • [482bfe272a] - deps: update eslint-plugin-flowtype to version 2.11.4 (#344) (Greenkeeper)
  • [0e66aa5405] - deps: update flow-bin to version 0.31.1 🚀 (#341) (Greenkeeper)
  • [6e88a55c08] - deps: update babel-plugin-transform-es2015-modules-commonjs to version 6.14.0 (#343) (Greenkeeper)
  • [15b648aa77] - deps: update babel-core to version 6.14.0 (#342) (Greenkeeper)
  • [d33e6e67c3] - deps: update eslint-plugin-flowtype to version 2.11.1 (#339) (Greenkeeper)
  • [56e329f968] - docs: small readme typos/rephrasings (#330) (Kevin Barrett)
  • [bace2de2bd] - fix: errors occuring during application boot fail silently (#316) (Zachary Golba)
  • [b8c5815045] - deps: update rollup to version 0.34.10 (#328) (Greenkeeper)
  • [20f18a3459] - Feat: Ignoring build/dist folder (#327) (Adam Pash)
  • [98dcfe05ce] - deps: update eslint-plugin-flowtype to version 2.7.1 (#326) (Greenkeeper)
  • [d28529ffc6] - deps: update rollup to version 0.34.9 (#324) (Greenkeeper)
  • [86ea773e88] - deps: update eslint to version 3.3.1 (#323) (Greenkeeper)
  • [6501ad00a0] - Fix: Environment variables overwritten by lux CLI (#322) (Adam Pash)
  • [9868b3d54d] - Feat: Added ssl for database; fixed port (#319) (Adam Pash)
  • [55cc30ae2b] - Feat: Added minimum node version to package.json template (#321) (Adam Pash)
  • [612b9ced7a] - deps: update eslint-plugin-flowtype to version 2.7.0 (#318) (Greenkeeper)
  • [039dda77f2] - deps: update rollup to version 0.34.8 (#317) (Greenkeeper)
  • [2b2829fbca] - fix: model-less controllers prevent applications from starting (#315) (Zachary Golba)
  • [2c90cfa994] - deps: update test-app dependencies (#314) (Zachary Golba)
  • [e9df74a9ef] - chore: update examples (#313) (Zachary Golba)
  • [d1fbddc7b0] - release: 1.0.0-rc.5 (#312) (Zachary Golba)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc