- nodejs >= v14.7.0
- npm >= v6.4.7
- yarn >= v1.19.1
Clone project and run test.
$ git clone https://github.com/nvchau/meowlo
$ cd meowlo
$ yarn | npm install
$ yarn | npm start
- Use compiler
babeljs
and librarybabel-plugin-module-resolver
*/...
: go from root directory- Read more here:
- eslint
- Run: npm run eslint
- Use
mongoose npm
(MongoDB ORM - third-party libraries) ormongodb npm
(MongoDB NodeJS Driver - released by mongodb itself) mongoose npm
is easier to use, but performance lags behindmongodb npm
- I will choose
mongodb npm
- this is MongoDB native driver
- Use
mongodb clusters free for dev
- Use
joi npm
todeclare Schema
andvalidate
input data - Also can use
express-validator
to validate input data, but I only use one - Use
aggregate mongodb
aggregate data from collections to return desired results (https://www.mongodb.com/docs/manual/reference/method/db.collection.aggregate/), andlookup mongodb
- so that the query is similar to SQL'sleft outer join
(https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/)
- In mongodb, _id always has the data type of
ObjectId
, but when saving it as a string, there will be an error when querying, so there are 2 solutions:- Convert
_id
to string when hexadecimal (useaddFields
of mongodb) - When saving the database (specifically when creating new
column
and newcard
record) it is necessary to save the correctObjectId
, no need to convert when querying anymore (I choose this way)
- Convert
- Use
soft delete
, ie do not delete this record completely from the database, but update the field_destroy
fromfalse
totrue