There's a number of locations in the controller files that perform a "related collection check" to see if an associated WordSuggestion, ExampleSuggestion, or GenericWord already exist before attempting to create a new Word or Example document.
The Problem
These checks should happen with a Mongoose pre-find middleware so that logic doesn't muddy up the words.js and examples.js controllers files. The related WordSuggestion, ExampleSuggestion, and GenericWord ids are later used to update their merge properties with the following utils function: https://github.com/ijemmao/igbo_api/blob/master/src/controllers/utils/index.js#L95-L99
Background
There's a number of locations in the controller files that perform a "related collection check" to see if an associated
WordSuggestion
,ExampleSuggestion
, orGenericWord
already exist before attempting to create a newWord
orExample
document.The Problem
These checks should happen with a Mongoose pre-find middleware so that logic doesn't muddy up the
words.js
andexamples.js
controllers files. The relatedWordSuggestion
,ExampleSuggestion
, andGenericWord
ids are later used to update theirmerge
properties with the following utils function: https://github.com/ijemmao/igbo_api/blob/master/src/controllers/utils/index.js#L95-L99Words pre-find check
https://github.com/ijemmao/igbo_api/blob/master/src/controllers/words.js#L149-L157
Examples pre-find check
https://github.com/ijemmao/igbo_api/blob/master/src/controllers/examples.js#L67-L74