Socket
Socket
Sign inDemoInstall

ndjson-query-language

Package Overview
Dependencies
8
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ndjson-query-language


Version published
Weekly downloads
0
Maintainers
1
Created
Weekly downloads
 

Readme

Source


ndjson-query-language is a Newline delimited JSON (NDJSON) command-line interface and library for developers.

Use MongoDB-like pipelines to query your log files.

Usage

# install it
npm install --global ndjson-query-language

# run it
ndjson-query-language --file data.ndjson --output output.ndjson --pipelines pipelines.json

Sample Files

See Sample Files Here

Operators

{ "age": 20, "fullName": "Foo Bar" }
{ "age": 40, "fullName": "Hello World" }
{ "age": 80, "fullName": "John Doe" }

$contains

{
  "$match": {
    "fullName": { "$contains": "Doe" }
  }
}

Returns:

{ "age": 80, "fullName": "John Doe" }

$eq

Specifies equality condition. The $eq operator matches documents where the value of a field equals the specified value.

{
  "$match": {
    "fullName": { "$eq": "John Doe" }
  }
}

Returns:

{ "age": 80, "fullName": "John Doe" }

$exists

When is true, $exists matches the documents that contain the field, including documents where the field value is null. If is false, the query returns only the documents that do not contain the field.

{
  "$match": {
    "fullName": { "$exists": true }
  }
}

Returns:

{ "age": 20, "fullName": "Foo Bar" }
{ "age": 40, "fullName": "Hello World" }
{ "age": 80, "fullName": "John Doe" }

$gt

$gt selects those documents where the value of the field is greater than (i.e. >) the specified value.

{
  "$match": {
    "age": { "$gt": 30 }
  }
}

Returns:

{ "age": 40, "fullName": "Hello World" }
{ "age": 80, "fullName": "John Doe" }

$gte

$gte selects the documents where the value of the field is greater than or equal to (i.e. >=) a specified value (e.g. value.)

{
  "$match": {
    "age": { "$gte": 30 }
  }
}

Returns:

{ "age": 40, "fullName": "Hello World" }
{ "age": 80, "fullName": "John Doe" }

$lt

$lt selects the documents where the value of the field is less than (i.e. <) the specified value.

{
  "$match": {
    "age": { "$lt": 30 }
  }
}

Returns:

{ "age": 20, "fullName": "Foo Bar" }

$lte

$lte selects the documents where the value of the field is less than or equal to (i.e. <=) the specified value.

{
  "$match": {
    "age": { "$lte": 30 }
  }
}

Returns:

{ "age": 20, "fullName": "Foo Bar" }

$ne

$ne selects the documents where the value of the field is not equal to the specified value. This includes documents that do not contain the field.

{
  "$match": {
    "fullName": { "$ne": "John Doe" }
  }
}

Returns:

{ "age": 40, "fullName": "Hello World" }
{ "age": 80, "fullName": "John Doe" }

License

ndjson-query-language is open-source software distributed under the terms of the MIT license.

FAQs

Last updated on 13 Sep 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc