A non-mutable CRUD connector for Solr in TypeScript for LoopBack.io forked from Timo
- GET /api
- GET /api/{id}
- HEAD /api/{id}
- GET /api/{id}/exists
- GET /api/findOne
All loopback filters are supported except include. Currently, only equivalence is supported in where
-
Install in your LoopBack node project with
npm i adwiens/loopback-connector-solr --save
-
Make a model with the LoopBack CLI based on PersistedModel
-
Put the following in your model.js: (Disables unimplemented and mutable endpoints)
module.exports = function(Modelname) { Modelname.disableRemoteMethodByName('createChangeStream'); Modelname.disableRemoteMethodByName('upsert'); Modelname.disableRemoteMethodByName('updateAll'); Modelname.disableRemoteMethodByName('upsertWithWhere'); Modelname.disableRemoteMethodByName('create'); Modelname.disableRemoteMethodByName('replaceOrCreate'); Modelname.disableRemoteMethodByName('replaceById'); Modelname.disableRemoteMethodByName('deleteById'); Modelname.disableRemoteMethodByName('count'); Modelname.disableRemoteMethod('updateAttributes', false); // updateAttributes is not static - have to use this deprecated function };
-
Create a datasource in datasources.json:
{ "db": { "name": "db", "connector": "memory" }, "solr": { "name": "solr", "connector": "solr", "solr": { "host": "localhost", "port": 8983, "core": "your-core-name-goes-here" } } }
-
Hook up the datasource to your model in model-config.json:
{ "ACL": { "dataSource": "db", "public": false }, "modelname": { "dataSource": "solr", "public": true } }