drewwiens-spikes / loopback-connector-solr

A Solr CRUD connector in TypeScript for LoopBack 3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

loopback-connector-solr

A non-mutable CRUD connector for Solr in TypeScript for LoopBack.io forked from Timo

Supported endpoints

  • GET /api
  • GET /api/{id}
  • HEAD /api/{id}
  • GET /api/{id}/exists
  • GET /api/findOne

Supported filters

All loopback filters are supported except include. Currently, only equivalence is supported in where

Quick start

  1. Install in your LoopBack node project with

     npm i adwiens/loopback-connector-solr --save
    
  2. Make a model with the LoopBack CLI based on PersistedModel

  3. 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
    };
  4. 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"
        }
      }
    }
  5. Hook up the datasource to your model in model-config.json:

    {
      "ACL": {
        "dataSource": "db",
        "public": false
      },
      "modelname": {
        "dataSource": "solr",
        "public": true
      }
    }

About

A Solr CRUD connector in TypeScript for LoopBack 3

License:MIT License


Languages

Language:TypeScript 51.1%Language:JavaScript 48.9%