Socket
Book a DemoInstallSign in
Socket

ilorm-plugin-algolia

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ilorm-plugin-algolia

Plugin to add algolia to your project

0.1.1
latest
npmnpm
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

ilorm-plugin-algolia

This plugin adds binding between your data and algolia.

Schema

With this plugin enabled you can define which fields will be stored in your database and in algolia.

const { Schema } = require('ilorm');

const userSchema = new Schema({
  email: Schema.string().required().algolia(),
  firstName: Schema.string().required().algolia()
})

Declare model index

const algoliasearch = require('algoliasearch');
const { newModel } = require('ilorm');

const client = algoliasearch(CLIENT_ID, CLIENT_SECRET);

const UserModel = newModel({
  name: 'users',
  schema: userSchema,
  pluginsOptions: {
    algolia: {
      index: client.index('users'),
    },
  },
  connector: // ...
})

With algolia enabled on your model, you will have a new search method on the query

const User = require('./user.model');

const user = await User.query()
    .search('smith')
    .findOne();

How it's work?

  • At save and remove classic model method, the associated algolia index will be updated (upsert instance or remove from index).
  • At query, the Query will first search in algolia, and filtering with the returning ObjectId the query to the main database.

Keywords

plugin

FAQs

Package last updated on 05 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.