loopbackio / loopbackio/loopback-connector
Connector helpers to obtain INDEX and FOREIGN KEY configurations from model definitions
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 35
- Forks
- 102
- Avg merge
- 14h 26m
- Merged PRs (30d)
- 13
Description
_This is a follow-up task for the proposal outlined in https://github.com/strongloop/loopback-next/issues/2712._
Implement a helper functions in base `Connector` class to process index and foreign-key definitions in an unified way and convert them into data suitable for consumption by connector implementations. The helpers should gather both model-level and property-level definitions, apply database/connector-specific options, merge keys/properties fields in index definitions, etc. and produce a final definition that can be directly mapped to database commands.
See `_SPIKE_.md` in https://github.com/strongloop/loopback-next/pull/2712 for the full description of index/PK definition syntax.
This is a prerequisite for implementation of indexes & foreign keys in other connectors, most notably memory connector (https://github.com/strongloop/loopback-next/issues/2333) and `SqlConnector` (https://github.com/strongloop/loopback-connector-rest/issues/135)
## Acceptance criteria
- [ ] Implement a helper to process INDEX definitions, include tests and API docs
- [ ] Implement a helper to process FOREIGN KEY definitions, include tests and API docs
- [ ] Deprecate [ModelDefinition.prototype.indexes()](https://github.com/strongloop/loopback-datasource-juggler/blob/fe83f3cfd11f3fa313a5f9a253149a3b8479a572/lib/model-definition.js#L194) API in favor of this new Connector method.
- Create follow-up tasks to leverage the new helper in our NoSQL connectors and thus let the connectors understand the new FK/INDEX definition syntax. One GH issue per connector please.
- [ ] MongoDB
- [ ] CouchDB
- [ ] Cloudant
- [ ] Cassandra
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the proposal in issue #2712 and its _SPIKE_.md description for the index and foreign-key definition syntax. Review ModelDefinition.prototype.indexes() in lib/model-definition.js and identify the base Connector entry point for the new helpers. Done means both helpers have tests and API docs, the old API is deprecated, and follow-up connector tasks are recorded.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100