-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
The memory connector should enforce foreign key and uniqueness constraints for HasMany, HasOne and BelongsTo relations.
For example, when creating an order using /post/{userId}/orders for a userId which is not that of a user, I would've expected some sort of a check that would've ensure that the userId exists. The connector should throw an error for an userId not in the database.
See #1718 for background and #2332 for the SQL story.
See https://github.com/strongloop/loopback-connector-rest/issues/134 for a Connector helper to parse different styles of index/fk definitions into a format that's easy to consume by connectors.
Acceptance criteria
- Modify the built-in
memoryconnector to enforce unique indexes defined at model and property level, leverage the new helper implemented by https://github.com/strongloop/loopback-connector-rest/issues/134. See Sugarresponsedecorators for easier controller config #1672 for the description of different ways on how model indexes can be defined. See feat: add unique index support on create for in-memory connector loopback-datasource-juggler#1672 for prior implementation that was not finished. - Modify the buit-in
memoryconnector to enforce FOREIGN KEY constraints defined at model and property level, leverage the new helper implemented by https://github.com/strongloop/loopback-connector-rest/issues/134. See Sugarresponsedecorators for easier controller config #1672 for the description of different ways on how model indexes can be defined. - Warn the user about index/foreign-key options that are not supported by
memoryconnector (see out-of-scope below).
Out of scope
- "Plain" indexes without uniqueness check
onUpdateandonDeleteoptions for foreign keys