Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ucast/mongo

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ucast/mongo

git@github.com:stalniy/ucast.git

  • 2.4.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
557K
increased by10.14%
Maintainers
1
Weekly downloads
 
Created

What is @ucast/mongo?

@ucast/mongo is a package that allows you to apply conditions and filters to MongoDB queries using a unified and flexible syntax. It is part of the UCAS (Universal Conditions and Specifications) library, which provides a way to define and evaluate conditions in a consistent manner across different platforms and databases.

What are @ucast/mongo's main functionalities?

Creating Conditions

This feature allows you to create complex conditions using MongoDB's query syntax. The example demonstrates how to create a condition that checks if the age is greater than 18 and the name matches a regex pattern.

const { createCondition } = require('@ucast/mongo');

const condition = createCondition({
  $and: [
    { age: { $gt: 18 } },
    { name: { $regex: 'John' } }
  ]
});

console.log(condition);

Evaluating Conditions

This feature allows you to evaluate conditions against a given data object. The example shows how to evaluate if the age in the data object is greater than 18.

const { evaluateCondition } = require('@ucast/mongo');

const condition = { age: { $gt: 18 } };
const data = { age: 20 };

const result = evaluateCondition(condition, data);

console.log(result); // true

Combining Conditions

This feature allows you to combine multiple conditions using logical operators like $and, $or, etc. The example demonstrates how to combine two conditions using the $and operator.

const { combineConditions } = require('@ucast/mongo');

const condition1 = { age: { $gt: 18 } };
const condition2 = { name: { $regex: 'John' } };

const combinedCondition = combineConditions('$and', [condition1, condition2]);

console.log(combinedCondition);

Other packages similar to @ucast/mongo

Keywords

FAQs

Package last updated on 15 Feb 2023

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