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

drizzle-condition

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drizzle-condition

An alternative, intuitive way to declare drizzle SQL conditions

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

drizzle-condition

All Contributors

Simple utilities to define a drizzle-orm condition, without having to import the individual comparator functions. Instead use a single function with logical comparison operators to define the condition.

[!Warning] This library is a work in progress, and is not yet ready for production use.

Installation

Install the package from npm:

npm install drizzle-condition

Usage

import { integer, sqliteTable } from "drizzle-orm/sqlite-core";
import { condition } from "drizzle-condition";

const myTable = sqliteTable("my_table", {
    id: integer("id"), 
});

const myQuery = await myDatabaseConnection.query.myTable.findMany({
    // where: eq(myTable.id, 1), <-- drizzle-orm implementation eq, gt, lt, etc
    where: condition(myTable.id, "==", 1),// <-- drizzle-condition implementation '==', '!=', '>', '<', '>=', '<=' etc
});

Why?

I enjoy using the mathmatical operator syntax when building queries, much like firebase and other ORMs, and found myself writing helpers in all my projects to write the queries in this format.

Hopefully this library will make it easier for you to write queries this way too.

API Compatability

drizzle-ormdrizzle-condition
eqcondition(table.column, "==", value)
ne⏱️ todo
gt⏱️ todo
lt⏱️ todo
gte⏱️ todo
lte⏱️ todo
in⏱️ todo
isNull⏱️ todo
isNotNull⏱️ todo
inArray⏱️ todo
notInArray⏱️ todo
exists⏱️ todo
notExists⏱️ todo
between⏱️ todo
notBetween⏱️ todo
like⏱️ todo
notLike⏱️ todo
ilike⏱️ todo
notIlike⏱️ todo
not⏱️ todo
and⏱️ todo
or⏱️ todo
arrayContains⏱️ todo
arrayContainedIn⏱️ todo
arrayOverlaps⏱️ todo

Contributing

Contributions are welcome!

Project Structure

Package manager: bun Test runner: vitest Linter: biome

Get stated

  1. Fork the repository
  2. Install dependencies: bun install
  3. Check the project is working: bun run all
    1. This runs type checking, building, linting and testing. See the package.json for more details.

Making a PR

Create a pull request to the main branch from your forked repository.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

FAQs

Package last updated on 25 May 2024

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