- Required mongodb:
mongod
command - Windows, Develop:
npm run windowsDebug
command
Trade off between query performance vs consistency
- Using References (Normalization) -> CONSISTENCY
let author = {
name: 'Travis Scott'
}
let book = {
author: 'id'
}
- Using Embedded Documents (Denormalization) -> PERFORMANCE
let book = {
author: {
name: 'Travis Scott'
}
}
- Hybrid approach mongodb (best for small shops)
let author = {
name: 'Travis Scott'
... // and other prorerties
}
let book = {
author: {
id: 'referral',
name: 'Travis Scott'
}
}
- eq (equal),
- ne (not equal),
- gt (greather than)
- gte (greathe than or equal to)
- lt (less than)
- lte (less than or equal to)
- in
- nin (not in)
- or
- and
Examples { <field>: /pattern/<options> }
:
- Start with Tolkien
.find ({ author: /^Tolkien/ })
- Ends with Tolkien
.find ({ author: /Tolkien$/i })
- Contain Tolkien
.find ({ author: /.*Tolkien.*/ })
.count();