Skip to content

selego/mongoose-elastic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Index Mongoose models into Elasticsearch automatically

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors