search-alchemy

1.0.1 • Public • Published

MIT licensed Build Status Coverage Status

Abstract

Search Alchemy is a thin wrapper around the elasticsearch client library for javascript and provides a mongo-like interface for basic CRUD actions and queries.

Its main goal is to provide a powerful search interface for basic projects that only require simple CRUD functionality, removing a dependency on a database management system which elasticsearch provides anyways.

Install with yarn or npm

npm install --save search-alchemy
yarn add search-alchemy

Usage

const SearchAlchemy = require('search-alchemy');
const search = new SearchAlchemy();

// insert a document
let document = { name: "Ben", tags: [1, 2, 3] }
search.Insert(document)
      .then(function(result){console.log("inserted!")})  
      .catch(function(err){console.log(err)})
      
// query a document by id
search.FindById(someId)      
      .then(function(result){console.log("found!")})  
      .catch(function(err){console.log(err)})
      
// query 100 documents
search.Find(100)  
      .then(function(result){console.log("found!")})  
      .catch(function(err){console.log(err)})
      
// update a document by id  
search.UpdateById(someId, { name: "fred" })      
      .then(function(result){console.log("updated!")})  
      .catch(function(err){console.log(err)})
        
// delete a document by id
search.DeleteById(someId)      
      .then(function(result){console.log("deleted!")})  
      .catch(function(err){console.log(err)})          

Readme

Keywords

none

Package Sidebar

Install

npm i search-alchemy

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • b3ntly