I have a model definition as such (snipped for sake of readability):
{
"name": "PlannerArchive",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true,
"strictObjectIDCoercion": true
},
"properties": {
"planner": {
"type": "object",
"required": true
},
"event": {
"type": "string",
"required": true
},
"user": {
"type": "string",
"required": true
}
},
"indexes": { <<<<<<<<<<<<<<<<<<<<<<<<
"event_idx": {
"keys": {
"event": 1
}
},
"user_idx": {
"keys": {
"user": 1
}
}
}
}
My expectation is that when the server has started up and the collection has been created - that the indexes be created as well.
The reality is that the collection is created, and a PK index on generated "id" is created - but none of my custom indexes are.
I can run code on server boot that looks something like mongoDS.autoupdate()
that will create them, but was rather hoping not to need to do this.
Is my understanding of loopbacks index handling flawed - or is there something else I can do?
Apologies for still running Loopback 3.x - the migration is in the pipeline.
When adding indexes, you need an auto-update script.
Add it in
/server/boot/autoupdate.js
: