🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

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

1.0.3
latest
Source
npm
Version published
Weekly downloads
6
200%
Maintainers
1
Weekly downloads
 
Created
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

elasticsearch

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