Giter Site home page Giter Site logo

drizzle-condition's Introduction

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: and(eq(myTable.id, 1), eq(myTable.name, "John")), <-- drizzle-orm implementation eq, gt, lt, etc
    where: condition(myTable.id, "==", 1).and(condition(myTable.name, "==", "John")), // <-- drizzle-condition implementation 
});

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-orm drizzle-condition
eq condition(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 condition(table.column, "==", value).and(condition(table.column, "==", value))
or condition(table.column, "==", value).or(condition(table.column, "==", value))
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!

drizzle-condition's People

Contributors

kaispencer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.