@selego/mongoose-elastic
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

Mongoose Elastic

Mongoose Elastic is a mongoose plugin that can automatically index your models into elasticsearch.

Version Downloads/week License

Usage

Install the package.

npm i @selego/mongoose-elastic

Setup your mongoose model to use the plugin.

const { Client } = require("@elastic/elasticsearch");
const mongoose = require("mongoose");
const mongooseElastic = require("@selego/mongoose-elastic");

const client = new Client({ node: "http://localhost:9200" });

const User = new mongoose.Schema({
  name: String,
  email: String,
  city: String,
});

User.plugin(mongooseElastic(client), "user");

module.exports = mongoose.model("user", User);

Then, use your mongoose model as usual:

const user = new User({ name: "Raph" });
user.save().then(() => {
  console.log("user saved on mongo, elastic sync is on its way");
});

Why

There are some competitors, still, most of them are abandonned or suffering from their legacy.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.6.0
    540
    • legacy
  • 3.0.0
    1
    • latest

Version History

Package Sidebar

Install

npm i @selego/mongoose-elastic

Weekly Downloads

541

Version

3.0.0

License

MIT

Unpacked Size

26 kB

Total Files

7

Last publish

Collaborators

  • naustra
  • naei
  • gauthier-th
  • rap2hpoutre