You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

query-orm-connector-elastic

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

query-orm-connector-elastic

elasticsearch connector for query-orm


Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

query-orm-connector-elastic

Elasticsearch 7.x Connector for query-orm

npm version

Installation

npm i query-orm
npm i query-orm-connector-elastic

Usage

app.js

const QueryORM = require('query-orm');

const app = new QueryORM({
  appRoot: DIRNAME,
  modelConfig: './model-config.json',
  dataSources: './datasource.json'
});

app.on('model-init', (data) => {
  console.log(data);
});

app.on('error', (error) => {
  console.log(error);
});

async function createUser (data) {
  const createdUser = await app.models.User.create(data);
  return createdUser;
}

createUser({
  firstname: 'Bharath',
  lastname: 'Reddy',
  username: 'bharathreddy',
  password: 'Test@1234'
}).then((createdUser) => {
  console.log(createdUser)
}).catch((error) => {
  console.log(error);
});

app.models.User.find({
  where: {
    username: 'bharathreddy'
  }
}).then((result) => {
  console.log(result)
}).catch((error) => {
  console.log(error);
});

datasources.json

{
  "testdatasource": {
    "name": "testdatasource",
    "settings": {
      "indexName": "testindex",
      "isAlias": false,
      "isPattern": false,
      "mappings": {
        "properties": {
          "docType": {
            "type": "keyword"
          },
          "userId": {
            "type": "keyword"
          },
          "username": {
            "type": "keyword"
          },
          "firstname": {
            "type": "keyword"
          },
          "lastname": {
            "type": "keyword"
          },
          "password": {
            "type": "keyword"
          },
          "created": {
            "type": "date"
          },
          "updated": {
            "type": "date"
          }
        }
      },
      "aliases": {},
      "indexSettings": {
        "number_of_shards": 1,
        "number_of_replicas": 2
      },
      "createIndex": true,
      "updateMapping": true,
      "version": 7,
      "defaultLimit": 200,
      "configuration": {
        "nodes": [
          "https://localhost:9200"
        ],
        "requestTimeout": 30000,
        "pingTimeout": 3000,
        "auth": {
          "username": "admin",
          "password": "admin"
        },
        "agent": {
          "maxSockets": 1,
          "keepAlive": false
        },
        "ssl": {
          "rejectUnauthorized": false
        },
        "sniffInterval": 10000
      }
    },
    "connector": "query-orm-connector-elastic",
    "localConnector": false
  }
}

Example

  • Checkout example here
  • To run example app, copy folder and npm install both query-orm and query-orm-connector-elastic
  • run
node app.js

Keywords

FAQs

Package last updated on 29 Apr 2021

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc