Commit Graph

824 Commits

Author SHA1 Message Date
Raymond Feng 4b9d98c6ce Allows skip or offset
See https://github.com/strongloop/loopback/issues/336
2014-06-17 09:07:55 -07:00
Raymond Feng e2ab9ccc93 Adding back the remoting metadata 2014-06-16 13:46:17 -07:00
Raymond Feng 046816191d Clean up scope implementation 2014-06-16 10:50:42 -07:00
Raymond Feng 2db43c58e5 Add support for hasOne 2014-06-16 01:17:37 -07:00
Raymond Feng 34c1998f04 Fix the hasMany through connection 2014-06-16 00:36:12 -07:00
Raymond Feng 1406c22a64 Refactor relation into classes 2014-06-15 15:53:58 -07:00
Raymond Feng 0c13f8c23a Merge pull request #132 from strongloop/feature/memory-connector-comparator
Feature/memory connector comparator
2014-06-13 11:46:52 -07:00
crandmck 1787f5ec4f Add properties and other doc cleanup 2014-06-11 15:47:44 -07:00
Alberto Leal 4fd3c969f9 Convert null to NotFoundError for remoting call to DataAccessObject.findOne. 2014-06-11 16:59:21 -03:00
Raymond Feng bb57fcbe11 Fix the comparison for null/boolean values 2014-06-10 16:11:50 -07:00
crandmck c355c99cbd More JSDoc cleanup 2014-06-10 14:27:58 -07:00
Raymond Feng 6e8034ff93 Fix the forEach closure 2014-06-06 09:59:57 -07:00
Raymond Feng e0d3fec743 Fix the typo 2014-06-06 09:10:47 -07:00
Raymond Feng 0191e3c2db Add more tests 2014-06-06 08:48:05 -07:00
Raymond Feng a0a9fae9c6 Enhance comparators for memory connector 2014-06-06 08:19:41 -07:00
Rand McKinney 04e1256b8b Update datasource.js
Fix small typo
2014-06-04 17:44:57 -07:00
Raymond Feng 5f3c856d2e Fix the logical operator check 2014-06-04 14:23:53 -07:00
Raymond Feng cdf9956867 Fix JS doc for private methods 2014-06-04 14:02:55 -07:00
Raymond Feng 42c1ad3dca Normalize/validate the query filter object 2014-06-02 15:57:44 -07:00
Raymond Feng 3e8284d1ee Use connector's buildWhere to implement count 2014-06-02 15:57:06 -07:00
Rand McKinney 653aab856c JSDoc improvements
Improve createModel doc, Fix some other minor issues.
2014-05-29 15:33:01 -07:00
Miroslav Bajtoš d8b4f5833a ModelBuilder: add `prototype.defineValueType`
Add a shortcut for registering a new value type.

The current implementation registers the type in the singleton registry
`ModelBuilder.schemaTypes`.

The API should allow us to to change the implementation to register
the type in the scope of ModelBuilder instance only.
2014-05-29 11:57:59 +02:00
Miroslav Bajtoš a86648ed7b Replace connector base with loopback-connector
Remove references to Connector and BaseSQL, connectors should require()
loopback-connector instead of loopback-datasource-juggler.
2014-05-29 11:57:49 +02:00
Miroslav Bajtoš 9b33d9a274 Remove unsupported connectors
- cradle
 - http
 - neo4j
 - riak
2014-05-28 19:49:07 +02:00
Raymond Feng 97b1501c1f Keep undefined/null values for the array type
This allows connectors to distinguish between empty array and
undefined/null. For example, mongodb will not override existing array
properties if the value is undefined.
2014-05-27 21:59:21 -07:00
crandmck 83979cad7a Remove JSDocs for scopeMethods.add(acInst) and scopeMethods.remove(acInst) 2014-05-27 21:59:21 -07:00
crandmck 835708d25d Copy info from api-model.md to JSDoc 2014-05-27 21:59:21 -07:00
Miroslav Bajtoš 65fa7a1c00 validations: include more details in `err.message`
Modify ValidationError constructor to include the model name and
a human-readable representation of the validation errors (messages)
in the error message.

Before this change, the message was pointing the reader
to `err.details`.  Most frameworks (e.g. express, mocha) log only
`err.message` but not other error properties, thus the logs were
rather unhelpful.

Example of the new error message:

    The `User` instance is not valid. Details: `name` can't be blank.
2014-05-27 21:59:21 -07:00
Raymond Feng 050353f11d Keep undefined/null values for the array type
This allows connectors to distinguish between empty array and
undefined/null. For example, mongodb will not override existing array
properties if the value is undefined.
2014-05-27 13:18:21 -07:00
crandmck 5937f0c0d5 Remove JSDocs for scopeMethods.add(acInst) and scopeMethods.remove(acInst) 2014-05-22 15:02:57 -07:00
crandmck 00226dde0d Copy info from api-model.md to JSDoc 2014-05-21 17:50:44 -07:00
Ritchie Martori 69b0355fa7 Merge pull request #115 from strongloop/refactor/remove-remoting
Remove remoting metadata
2014-05-20 13:59:33 -07:00
Ritchie Martori 8849a4b49a !fixup Remove additional remoting 2014-05-20 13:48:23 -07:00
Ritchie Martori e724efd95f !fixup Require ._delegate for fn override 2014-05-20 13:44:25 -07:00
Ritchie Martori 072999775e Remove relation remoting 2014-05-20 12:47:14 -07:00
Miroslav Bajtoš 05410d56e1 validations: include more details in `err.message`
Modify ValidationError constructor to include the model name and
a human-readable representation of the validation errors (messages)
in the error message.

Before this change, the message was pointing the reader
to `err.details`.  Most frameworks (e.g. express, mocha) log only
`err.message` but not other error properties, thus the logs were
rather unhelpful.

Example of the new error message:

    The `User` instance is not valid. Details: `name` can't be blank.
2014-05-20 11:00:19 +02:00
Ritchie Martori dc9c9b2bd4 Remove remoting metadata 2014-05-16 12:33:17 -07:00
Raymond Feng 981185f4c0 Merge pull request #112 from strongloop/feature/logical-operator
Add support for logical operator (AND/OR)
2014-05-16 08:46:25 -07:00
Adam Schwartz 49f0e5dcee Fix typo "Unkown" => "Unknown" 2014-05-15 23:26:17 -04:00
crandmck ba3653d406 Updated JSDoc comments with content from .md file 2014-05-15 17:59:23 -07:00
Raymond Feng 8f9dc1b867 Add support for logical operator (AND/OR) 2014-05-15 08:56:00 -07:00
Miroslav Bajtoš 2a74bdc4de validations: support multi-key unique constraint
Modify the "unique" validator to accept additional property names to
narrow the space of rows searched for duplicates.

Example:

Consider `SiteUser` belongsTo `Site` via `siteId` foreign key.
Inside every site, the user email must be unique. It is allowed to
register the same email with multiple sites.

    SiteUser.validateUniquenessOf('email', { scopedTo: ['siteId'] });
2014-05-15 09:15:44 +02:00
crandmck 1db35cc926 Update JSDoc comments with content from api-model.md 2014-05-14 18:30:42 -07:00
Rand McKinney affe3cd943 Add JSDoc for lat and lng properties. 2014-05-14 16:34:24 -07:00
Ritchie Martori 2922eb63b7 Merge 2014-05-14 13:33:46 -07:00
Ritchie Martori ad752747d3 Add missing changed event 2014-05-14 13:31:15 -07:00
Ritchie Martori 6c91201f79 Local Storage 2014-05-14 13:31:15 -07:00
Ritchie Martori 0866a55cb2 Do not .toObject if already Object 2014-05-14 13:31:15 -07:00
Zack Bloom dd4089d1c7 Fix bug where invalid relations in include filters would hang the server 2014-05-13 13:59:15 -04:00
Raymond Feng 3f410cae21 Add test cases for updateOrCreate/save and fix related issues 2014-05-09 15:27:45 -07:00
Raymond Feng 0bcbe6ceae Remove undefined for the data to be saved 2014-05-09 09:59:34 -07:00
Raymond Feng 4a907b0a18 Remove the undefined property to avoid mongodb upsert overwrite 2014-05-08 15:46:39 -07:00
Raymond Feng 8b128b566d Make sure ObjectID type is not parsed as object 2014-05-08 15:46:14 -07:00
crandmck cf75f55f73 Fix JSDoc - remove newlines from function alias declarations, etc. 2014-05-07 11:24:49 -07:00
Rand McKinney a765ea31ab Correct JSDoc for discoverModelDefinitions 2014-05-06 14:18:10 -07:00
Ritchie Martori 45eadabbeb Fix remoting for IDs in URLs 2014-05-01 14:19:31 -07:00
Ritchie Martori aea5836569 Add hidden property support 2014-04-11 11:39:57 -07:00
Miroslav Bajtoš 440dfaf3a7 scope-like remotable metadata for belongsTo
Modify the methods created by `belongsTo` relation to mimick the methods
created by scopes (e.g. via `hasMany` relation).

This allows client code generators like loopback-angular to use the same
code for all relation types.
2014-04-08 10:30:57 +02:00
Raymond Feng a1f8919e13 Merge pull request #98 from strongloop/feature/fix-issue-97
Fix the method for belongsTo with correct receiver
2014-04-04 08:27:55 -07:00
Raymond Feng 68d2696248 Fix the method for belongsTo with correct receiver 2014-04-03 20:41:53 -07:00
Miroslav Bajtoš d08c6714d8 scope: improve description of shared methods
The description is used by client SDK code-generators like
loopback-angularjs.
2014-04-03 09:19:06 +02:00
Miroslav Bajtoš abf57ff497 scope: add _targetClass to scope property
Store the class of the results returned by a scope find method.
This class is different from the "targetClass" when the relations
is using a third "through" model (e.g. hasAndBelongsToMany).
2014-04-02 19:32:37 +02:00
Raymond Feng c79d0b0c33 Merge pull request #92 from strongloop/feature/fix-issue-91
Fix the base sql connector to correct escape id values
2014-03-27 14:34:46 -07:00
Raymond Feng c28546b629 Fix the base sql connector to correct escape id values
This is based on https://github.com/strongloop/loopback-datasource-juggler/pull/91
https://github.com/strongloop/loopback-datasource-juggler/issues/90
2014-03-24 14:56:52 -07:00
Raymond Feng 0e7acec591 Set the relation property correctly
See https://github.com/strongloop/loopback/issues/218
2014-03-23 21:07:04 -07:00
Raymond Feng cc5975486d Simplify the inclusion processing 2014-03-17 08:40:40 -07:00
Raymond Feng cadacc44bb Create scoped methods for belongsTo and improve docs 2014-03-17 08:40:40 -07:00
Raymond Feng 1dc0c34252 Fix the connector resolver to make sure known connectors are used 2014-03-17 08:32:37 -07:00
Raymond Feng bef90bd529 Refactor the serialize/deserialize into two functions 2014-03-17 08:32:37 -07:00
crandmck aa11aad298 Fix some small errors 2014-03-13 16:26:29 -07:00
crandmck 9c2098cd35 Updates to JSDoc comments for API doc 2014-03-12 16:28:46 -07:00
Raymond Feng 464d23891b Merge pull request #82 from strongloop/feature/ldl-scopes
Allows scopes to be defined in LDL
2014-03-04 09:50:27 -08:00
Raymond Feng d14c58775d Use debug module for logging 2014-03-04 09:42:55 -08:00
Raymond Feng ab8076d44a Merge pull request #80 from strongloop/feature/remoting-belongsTo
Make the belongsTo relation remotable
2014-03-04 08:57:57 -08:00
Raymond Feng ed7e2e2ada Fix the parameter name 2014-03-04 08:56:16 -08:00
Raymond Feng 24c4381221 Allows scopes to be defined in LDL 2014-03-03 17:16:37 -08:00
Raymond Feng 510f5ef6ac Check the Array type
See https://github.com/strongloop/loopback-connector-mongodb/issues/21
2014-03-03 15:52:49 -08:00
Raymond Feng 14745b1305 Make the belongsTo relation remotable 2014-03-03 15:03:05 -08:00
Raymond Feng 925402fdb6 Merge pull request #78 from pandaiolo/master
Fix, model builder setter will not try to cast value if already the proper type
2014-02-27 10:38:28 -08:00
Aurelien Chivot dfe1ea1655 Fix, model builder setter will not try to cast value if already the proper type 2014-02-26 21:10:15 +01:00
Raymond Feng 44a62d01af Allows unknown properties to be saved for non-strict models
See https://github.com/strongloop/loopback/issues/199
2014-02-24 18:38:45 -08:00
Ritchie Martori 8ae292539e Merge pull request #74 from strongloop/feature/dao-override
Override existing methods when mixing in DAO methods
2014-02-21 09:04:52 -08:00
Ritchie Martori dd597d2197 Refactor mixin and always redefine proxy/delegate methods 2014-02-20 17:25:07 -08:00
Ritchie Martori 38c7a16da2 Override existing methods when mixing in DAO methods 2014-02-19 17:10:56 -08:00
Raymond Feng 9192c27409 Leave the item type introspection for List 2014-02-14 11:21:30 -08:00
Raymond Feng 12a624d99c Rewrite the List class for typed array 2014-02-14 10:41:00 -08:00
Raymond Feng 7e45a1fda1 Fix the include with array value 2014-02-14 10:40:45 -08:00
Raymond Feng 061b274055 Merge branch 'partial-fix-for-58' of github.com:arlaneenalra/loopback-datasource-juggler 2014-02-12 21:55:53 -08:00
Raymond Feng dbd97eb423 Merge pull request #68 from strongloop/feature/fix-lb-162
Make sure own properties are copied by toObject for non-strict mode
2014-02-11 14:29:21 -08:00
Raymond Feng 85232f31b3 Clean up the options for model constructor 2014-02-10 22:38:59 -08:00
arlaneenalra 5252d0e805 Move new var into thunk.
There really was no reason for it to be in the
outer context.
2014-02-05 22:21:27 -06:00
arlaneenalra abd46961da Use type converted data when writing back to database.
This allows foreignKey types and other custom types
to be converted into natvie values before writing them
to the database.
2014-02-04 23:10:42 -06:00
Raymond Feng 1961fbeefe Enhance the assertions 2014-02-03 20:52:01 -08:00
Ritchie Martori 61a54da418 Merge pull request #65 from strongloop/feature/change-hook
Add change / delete events
2014-01-30 13:54:47 -08:00
Raymond Feng ee5b351398 Make sure own properties are copied by toObject for non-strict mode
See https://github.com/strongloop/loopback/issues/162
2014-01-30 11:51:34 -08:00
Raymond Feng da571c0c23 Use String[] for types and add test for supported types 2014-01-29 17:19:07 -08:00
Raymond Feng cf200a2e27 Add getType/getDefaultIdType from connectors 2014-01-29 17:19:07 -08:00
Raymond Feng e65d21dcdb Merge pull request #67 from strongloop/feature/memory-persistence
Add an option for the memory connector to persist model instances
2014-01-29 17:18:00 -08:00
Raymond Feng 130dcdb582 Fix the write closure to use the correct task info 2014-01-29 13:41:42 -08:00
Raymond Feng 6b535f5d1c Add a file option for the memeory connector to persist data 2014-01-29 12:04:09 -08:00
Ritchie Martori e909749455 Add tests for change / delete events 2014-01-29 11:03:04 -08:00
Raymond Feng c008c4d30a Add more comments 2014-01-28 23:01:11 -08:00
Raymond Feng 2a57a909f0 Clean up lookupModel 2014-01-28 18:00:12 -08:00
Raymond Feng 43637a690d Handle hasMany.though 2014-01-28 17:59:59 -08:00
Ritchie Martori bef1bc1ca4 Add change / delete events 2014-01-28 13:51:45 -08:00
Raymond Feng 93c18163c8 Make sure __cachedRelations is not enumerable 2014-01-28 09:57:23 -08:00
Raymond Feng 1339250c8f Promote the included relations as properties 2014-01-27 15:56:04 -08:00
Raymond Feng 2b8c1ebaee Reformat the code 2014-01-24 09:09:53 -08:00
Raymond Feng 58a06272c3 Merge pull request #61 from strongloop/feature/fix-foreign-key
Use the primary key type for the generated foreign key
2014-01-24 08:31:02 -08:00
Raymond Feng c374cc89cd Use the primary key type for the generated foreign key 2014-01-21 09:47:32 -08:00
Miroslav Bajtoš dbb7c6d9ae Fill ModelClass.http.path
Set the HTTP route to `'/' + pluralModelName` so that we don't have
to duplicate this bit of logic in strong-remoting and other places.
2014-01-21 16:31:11 +01:00
Raymond Feng 2a50388894 Make the code testable following the review comments 2014-01-13 11:06:02 -08:00
Raymond Feng acd02bf482 Allows the full module name for connectors 2014-01-09 17:03:37 -08:00
Raymond Feng d9d9d82141 Add more comments 2013-12-20 17:49:14 -08:00
Raymond Feng f1773857bb Fix the remote delegation 2013-12-20 17:28:21 -08:00
Raymond Feng 1f965bfedb Fix the remoting method with the current receiver (this) 2013-12-20 14:47:41 -08:00
Raymond Feng e1ec152c78 Add models to LDL options
1. Use 'models' to specify the dependencies to other models
2. The 'models' property is an object, such as:

{
    Model1: 'Model1',
    Model2: Model2
}

3. The model classes will be injected into the newly defined class as
static properties using the keys from the models option.
2013-12-18 16:13:41 -08:00
Raymond Feng aabe5fb1c4 Fix a bug in merging ACLs 2013-12-16 17:14:56 -08:00
Raymond Feng 3d9061aa69 Make the identation consistent for now 2013-12-16 08:40:06 -08:00
Raymond Feng 1b9edbcfcb Fix a regression in mongodb connector 2013-12-15 22:51:47 -08:00
Raymond Feng 8d1d6f4466 Add more comments 2013-12-15 21:43:21 -08:00
Raymond Feng 9890af119e Check for null & undefined values 2013-12-14 09:54:28 -08:00
Raymond Feng fab504b5d9 Fix the coercion issue related to GeoPoint near 2013-12-14 09:49:11 -08:00
Raymond Feng bf592413e1 Dedupe the alias methods during mixin
To prevent the same method from showing up multiple times in API explorer,
for example, Model.deleteById, Model.removeById
2013-12-13 16:45:31 -08:00
Ritchie Martori 749a494e53 Always call inherits to ensure prototypes are setup 2013-12-13 11:27:29 -08:00
Raymond Feng 441596b870 Merge pull request #47 from strongloop/feature/query-coercing
Coerce query values of where clause based on property types
2013-12-10 10:09:42 -08:00
Raymond Feng 29405976fb Merge settings for base and sub models 2013-12-06 15:52:39 -08:00
Raymond Feng 2e4ed3f057 Merge pull request #48 from strongloop/feature/fix-discovery
Attach models to the data source
2013-12-05 15:40:43 -08:00
Raymond Feng e5824356ca Fix belongsTo relation 2013-12-04 21:38:40 -08:00
Raymond Feng 8360576c40 Attach models to the data source 2013-12-04 15:24:53 -08:00
Raymond Feng 52d2c8425f Make all methods proxied for DAO 2013-12-04 13:44:25 -08:00
Raymond Feng abe6d2bb22 Add more tests to address the PR comments 2013-12-04 10:00:33 -08:00
Raymond Feng ed6d8839ba Add a test case 2013-12-03 21:27:46 -08:00
Raymond Feng a953ba13de Clone shared methods so that they can be customized per model 2013-12-03 21:14:12 -08:00
Miroslav Bajtos b5e0035d73 Improve properties of ValidationError
- change `statusCode` from 400 to 422
- nest `context` and `codes` inside `details`
- add `details.messages`
- reword the main error message

Remove the call to Error's constructor from ValidationError constructor,
because it's a no-op - Error's constructor creates a new
instance when called via `.call()`.
2013-12-02 21:35:47 +01:00
Raymond Feng 2df0c4b21d Coerce types for values of where clause 2013-11-29 14:45:50 -08:00
Miroslav Bajtos f7c48c0d72 REST call of DataAccessObject.findById returns 404
Modify the remoting configuration of `DataAccessObject.findById()`
and add a `rest.before` handler that converts `null` to 404 error.

The change is covered by a test in loopback project.
2013-11-21 19:05:52 +01:00
Raymond Feng 8d9d73efff Add properties/methods to DataSource from ModelBuilder 2013-11-20 10:56:48 -08:00
Raymond Feng a53eac5307 Merge pull request #42 from strongloop/feature/fix-ds-attach
Fix the model attachment to data source
2013-11-19 10:56:55 -08:00
Raymond Feng 2bcdea76f5 Fix the model attachment to data source 2013-11-19 10:49:54 -08:00
Raymond Feng 05eae4aa3e Replace all with find to make it consistent 2013-11-18 11:39:07 -08:00
Raymond Feng 995a2139c8 Rename association to relation 2013-11-15 20:29:20 -08:00
Raymond Feng 7f6398f4c5 Fix the reference to modelBuilder/dataSource 2013-11-15 13:54:15 -08:00
Raymond Feng b5e0f14249 Separate the modelBuilder ref from dataSource 2013-11-15 11:12:33 -08:00
Raymond Feng 526d126e41 Fix the relation lazy setup 2013-11-11 22:06:43 -08:00
Raymond Feng 275bb6ffac Stop overwriting the static methods 2013-11-11 22:05:50 -08:00
Raymond Feng ec7f79e935 Ensure the model is attached to DataSource for relations 2013-11-09 22:16:32 -08:00
Raymond Feng 7aa2eefec4 Remove inheritence from DataSource to ModelBuilder 2013-11-08 17:13:00 -08:00
Raymond Feng 0b899b0542 Allow settings.base to specify the base model 2013-11-07 17:11:17 -08:00
Raymond Feng 580ce14f0d Extract the relation types 2013-11-07 13:30:54 -08:00