Commit Graph

35 Commits

Author SHA1 Message Date
Miroslav Bajtoš 7d674779e1 refactor: extract runtime and registry
Move isBrowser and isServer from lib/loopback to a new file lib/runtime.

Move all Model and DataSource related methods like `createModel` and
`createDataSource` to lib/registry.

Remove the circular dependency between lib/application and lib/loopback,
by loading lib/registry and/or lib/runtime instead of lib/loopback
where appropriate

This commit is only moving the code around, the functionality should
not be changed at all.
2014-06-12 10:41:44 +02:00
Miroslav Bajtoš fc0fad4a9f Add createModelFromConfig and configureModel()
Add new API allowing developers to split the model definition and
configuration into two steps:

 1. Build models from JSON config, export them for re-use:

  ```js
  var Customer = loopback.createModelFromConfig({
    name: 'Customer',
    base: 'User',
    properties: {
      address: 'string'
    }
  });
  ```

 2. Attach existing models to a dataSource and a loopback app,
    modify certain model aspects like relations:

  ```js
  loopback.configureModel(Customer, {
    dataSource: db,
    relations: { /* ... */ }
  });
  ```

Rework `app.model` to use `loopback.configureModel` under the hood.
Here is the new usage:

```js
var Customer = require('./models').Customer;

app.model(Customer, {
  dataSource: 'db',
  relations: { /* ... */ }
});
```

In order to preserve backwards compatibility,
`app.model(name, config)` calls both `createModelFromConfig`
and `configureModel`.
2014-06-12 10:41:44 +02:00
Miroslav Bajtoš 94ec5c294a app: implement `connector()` and `connectors`
Allow browserified applications to explicitly register connectors
to use in data-sources via `app.connector(name, exportsFromRequire)`.

Include built-in connectors like `Memory` and `Remote` in the registry.

Modify `dataSourcesFromConfig()` to resolve the connector via
`app.connectors` first and only then fall back to auto-require
the connector module.
2014-05-28 15:11:43 +02:00
Miroslav Bajtoš 7cfe450161 Make app.datasources unique per app instance
This removes a source of confusion in unit-tests.
2014-05-27 14:33:42 +02:00
Ritchie Martori 5298834c68 Merge branch 'master' into feature/remoting-connector 2014-04-14 11:01:20 -07:00
crandmck 006aca6b9c Update and cleanup JSDoc 2014-04-02 15:46:39 -07:00
Ritchie Martori dcdbef861e Add Remote connector 2014-03-27 14:47:29 -07:00
Ritchie Martori 57ff242308 Minor doc fix 2014-03-10 18:05:44 -07:00
Ryan Graham 088c2e2296 Merge fixup 2014-02-19 14:11:16 -08:00
Ritchie Martori 138821cf8b Merge package.json and lib/loopback.js 2014-02-19 11:44:44 -08:00
Raymond Feng 46b579dc4a Make sure User/AccessToken relations are set up by default
User.login assumes the relation User.accessTokens exists
2014-02-14 10:31:30 -08:00
Ritchie Martori e7f64a3abf Add karma for running browser tests 2014-02-12 10:17:02 -08:00
Miroslav Bajtoš b13ff35697 Make app.models unique per app instance
Remove a source of confusion in unit-tests.
2014-02-04 20:28:19 +01:00
Miroslav Bajtoš 20766e251a Add loopback.compat to simplify upgrade to 1.6
Add a compatibility layer that allows applications based on LB pre-v1.6
to work with 1.6 versions with a minimum amount of changes required.

New flag(s):
  compat.usePluralNamesForRemoting
2014-01-27 10:29:57 +01:00
Raymond Feng bcc7e68e0e Add lookback.getModelByType() and use it resolve model deps 2014-01-23 14:39:27 -08:00
Raymond Feng 8a114c635f Prevent autoAttach from overriding existing data source 2014-01-20 14:32:47 -08:00
Raymond Feng 5a6155e08e Clean up loopback.js doc and add it to docs.json 2014-01-17 10:40:41 -08:00
Raymond Feng 32bdce53ee Fix the jsdoc for loopback.getModel() 2014-01-17 10:23:59 -08:00
Ritchie Martori e7cc30ee03 Fix base class not being actual base class 2013-12-09 17:11:01 -08:00
Ritchie Martori 2f9403016c Initial auth implementation 2013-11-22 12:26:59 -08:00
Ritchie Martori aaa8423257 Fix minor autoWiring bugs 2013-11-20 14:18:54 -08:00
Ritchie Martori 9db8a7a25f Auto attach all models created 2013-11-19 12:23:02 -08:00
Ritchie Martori 178e5dab30 Remove .attachTo() from tests 2013-11-19 11:02:43 -08:00
Ritchie Martori da0545bed6 Initial auto wiring for model dataSources 2013-11-18 16:13:40 -08:00
Raymond Feng 9fddbc3834 Switch to modelBuilder 2013-11-15 11:16:20 -08:00
Raymond Feng 8381b05da1 Allows LDL level ACLs 2013-11-15 09:41:26 -08:00
Raymond Feng 67b934357b Start to build the ACL models 2013-11-14 21:19:56 -08:00
Ritchie 77a137eca6 Rename Session => AccessToken 2013-11-14 10:05:13 -08:00
Raymond Feng a00645dd83 Merge pull request #53 from strongloop/apns
Update Application model for the push notification
2013-11-06 11:50:56 -08:00
Raymond Feng 71339e159e Remove the proxy as it is now handled by the juggler 2013-10-24 20:40:33 -07:00
Raymond Feng bfffd839a7 Update Application model for the push notification 2013-10-11 13:56:26 -07:00
Raymond Feng 0d405d4292 Rename 'loopback-data' to 'loopback-datasource-juggler' 2013-07-30 14:26:49 -07:00
Ritchie 755b54f697 Fix hasMany / relational methods. Update docs. 2013-07-25 15:27:18 -07:00
Raymond Feng 1970f12988 Rename jugglingdb to loopback-data 2013-07-16 12:03:41 -07:00
Raymond Feng 1059a7b863 Add renamed files 2013-07-16 11:05:38 -07:00