New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ajoq

Package Overview
Dependencies
Maintainers
0
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajoq

Another Javascript Object Query.

  • 0.0.41
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5K
decreased by-37.73%
Maintainers
0
Weekly downloads
 
Created
Source

AJOQ

Another Javascript Object Query.

Github Build Status NPM version Downloads Snyk

Uses mongodb like query structure to execute in function

Installation

npm install ajoq

Usage

Filter function

import { createFilter } from "ajoq";

interface Data {
  name: string;
  age: number;
  // data type
}
const values: Data[] = [{ name: 'John', age: 42 }, { name: 'Jane', age: 18 }];

const filterFn = createFilter<Data>({ name: 'John', age: { $gte: 21 } });
const filtered = values.filter(filterFn); // [{ name: 'John', age: 42 }]

Sort function

import { createSort } from "ajoq";

interface Data {
  name: string;
  age: number;
  // data type
}
const values: Data[] = [{ name: 'John', age: 42 }, { name: 'Jane', age: 18 }];

const sortFn = createSort<Data>({ name: 'asc', age: -1 });
const sorted = values.toSorted(sortFn); // [{ name: 'John', age: 42 }, { name: 'Jane', age: 18 }]

Documentation

Filter

The Filter type represents a flexible and expressive way to filter and search data. It supports combining conditions with logical operators, making it suitable for complex query requirements.

Logical Operators
  • $and: Matches if all sub-conditions are true (logical AND).
  • $or: Matches if at least one sub-condition is true (logical OR).
  • $nor: Matches if none of the sub-conditions are true (logical NOR).
  • $not: Matches if the sub-condition is false (logical NOT).
Filter Operators
  • $eq: Matches if the field equals the value.
  • $ne: Matches if the field does not equal the value.
  • $gt: Matches if the field is greater than the value.
  • $gte: Matches if the field is greater than or equal to the value.
  • $lt: Matches if the field is less than the value.
  • $lte: Matches if the field is less than or equal to the value.
  • $exists: Matches if the field exists or does not exist (true or false).
  • $match: Matches if the field value matches a regex or string.
  • $nmatch: Matches if the field value does not match a regex or string.
  • $bits: Matches if any bits from the field value match the specified bitmask.
  • $nbits: Matches if no bits from the field value match the specified bitmask.
  • $type: Matches if the field's type matches the specified type.
  • $ntype: Matches if the field's type does not match the specified type.
  • $in: Matches if the field value is in the specified array.
  • $nin: Matches if the field value is not in the specified array.
  • $sub: Matches if all elements of the field array are in the specified array (subset).
  • $nsub: Matches if the field array is not a subset of the specified array.
  • $sup: Matches if the field array contains all elements of the specified array (superset).
  • $nsup: Matches if the field array does not contain all elements of the specified array.
  • $con: Matches if the field array contains the specified value.
  • $ncon: Matches if the field array does not contain the specified value.

License

License The MIT License Copyright (c) 2024 Ivan Zakharchanka

Keywords

FAQs

Package last updated on 12 Feb 2025

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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc