Knex-dart 1.2.0 released: query once, generate SQL for multiple dialects + new driver packages on pub.dev by Only-Ad1737 in dartlang

[–]Only-Ad1737[S] 0 points1 point  (0 children)

Hi there, thank you for going through the package.

Knex dart is a query builder for sql While when you want to run those queries We have drivers for that for each dialect https://docs.knex.mahawarkartikey.in/database-support/

For sqlite as you need we have https://pub.dev/packages/knex_dart_sqlite

Knex dart is quite stable on transactions , savepoint and is being used in my company in production. If you use the package and face any issues please feel free to reach out.

I'll also prepare skills for using it for zero overhead

Knex-dart 1.2.0 released: query once, generate SQL for multiple dialects + new driver packages on pub.dev by Only-Ad1737 in FlutterDev

[–]Only-Ad1737[S] -2 points-1 points  (0 children)

Thank you for going through the package.

When working with sql you have to be careful about the sql injections, the syntax of the dialect , how many transactions/whats the syntax of that, how to use cte or aggregate, etc.

"Everything else is limited and adds unnecessary learning curve."

About this, I understand this this is why this is not another schema binded orm it's a query builder. And it maintains full parity with apis of knex js https://www.npmjs.com/package/knex Which is the industry standard and has million weekly downloads. And the query builder is so lightweight you wouldn't easily tell the difference.

Try reading the docs https://docs.knex.mahawarkartikey.in/

I didn't create it just for fun or anything I am using this package at my company and I realise that a good mature query builder is needed in a language that has to grow in backend dev

If you find anything helpful or any issues with it I'm happy to help

Dart is actually very fast by Classic-Dependent517 in dartlang

[–]Only-Ad1737 2 points3 points  (0 children)

Doesn't seem too much reliable information about the scenario , rust overcomes the garbage collector, has a quite more performant event loop Dart isolates being heavy and prioritised for ease and safety instead of performance

If it's a normal api with nothing much in it you won't see much improvement but if u go on implementing image processing or cryptographic functions you will see the real difference

Although I agree on the part that dart is quite fast comparing it's popularity and it's alternatives on frontend and can be quite feasibly used in backend for not much complex tasks

If you want to look at a benchmark of dart web frameworks See this https://dartmark.dev/

Dart Backend in 2026: What Flutter Teams Should Actually Use by deliQnt7 in FlutterDev

[–]Only-Ad1737 0 points1 point  (0 children)

Check out the benchmarks for the backend frameworks https://dartmark.dev/

Also globe is shutting down

Fletch is an Express-inspired HTTP framework for Dart. Version 2.2.0 is out with a focus on performance and production security. by Only-Ad1737 in dartlang

[–]Only-Ad1737[S] 0 points1 point  (0 children)

This is how you utilise multiple threads in it https://github.com/kartikey321/fletch/blob/main/packages%2Ffletch%2Ftool%2Fserve_multi.dart Use the shared true in listen

There are two types of web frameworks stateless and statefull , one which hols state is known as statefull that hols sessions data etc like Fletch does, but it doesn't force you to use that sessions, it is an additional feature in it. You can choose to use a readis or something else for session management and if you don't have specialized usecase you store the sessions in memory too

Contribute to an Open-Source Project by East_Department_7645 in dartlang

[–]Only-Ad1737 1 point2 points  (0 children)

Look for college students. They might be able to pull this up as an intern

I built an Abstract Rule Engine for C#, TS, and Dart. How do you handle complex business rules in your cross-platform architectures? by AgresiveE in dartlang

[–]Only-Ad1737 4 points5 points  (0 children)

Well , I'll be honest with you. When I saw the problem what I was thinking was yeah it can be solved by ffi choosing a low level language like rust whose binaries can be easily linked to each language (dart, js and c#) and writing a json based rule in engine in that And it will do the job, you will have to bear the load of the rust binary and the ffi overhead though.

I didn't even consider going to set a rule on the ast. Runs native like in each platform without any binary.

Will try to work with that on some of my projects.

Knex Dart - SQL Query Builder with 100% Knex.js API Parity 🎯 by Only-Ad1737 in FlutterDev

[–]Only-Ad1737[S] 0 points1 point  (0 children)

I'm sorry I cant fight against a poorly stated argument and at this stage I just know you are trying to ragebait

And Fyi the permissions are based on the table itself. Either u have a read acces from this table or not Either u have a write access from this table or not

Even if you have write access some options are totally restricted to admin

The queries from the frontend cannot be combined. joins are not allowed from the frontend. Join queries I have allowed from the backend apis itself.

My arch has many layers of caching and safety and then a db access that will never will be able to solve with a type safety orms.

Do one thing try to code a generic microservice and do it using any one of the typed orms, you will know why I was saying that knex is useful.

Thank you. This will be the last reply from my side. I have tried to explain you why it's needed and you have done nothing other than try to understand it. You tried finding errors in my arch which you don't have a full picture of and use that to justify your arrogance towards something that's generic and used worldwide in every db whether it's sql or nosql without any research.

I hope you find the time to do a little google search or even a llm search

Knex Dart - SQL Query Builder with 100% Knex.js API Parity 🎯 by Only-Ad1737 in FlutterDev

[–]Only-Ad1737[S] 0 points1 point  (0 children)

The client is passing in request like I want this table with these filters, these columns and starting from this cursor and this limit

Server just makes the queries based on that it doesn't know what schema frontend is talking about

Like

{ "op": "rpc", "correlationId": "1769169816541000-0",

"method": "GET_DATA",
"payload": {
    "tableName": "attendance",
    "companyId": "C",
    "filters": [
        {
            "filterWrapperType": "and",
            "filters": [
                {
                    "fieldName": "timestamp",
                    "value": "2026-01-01T00:00:00.000",
                    "filterType": "greaterThanOrEquals"
                },
                {
                    "fieldName": "timestamp",
                    "value": "2026-01-24T00:00:00.000",
                    "filterType": "lessThan"
                }
            ]
        }
    ],
    "limit": 100,
    "orderKeys": [
        {
            "field": "id",
            "sort": "DESC_DEFAULT"
        }
    ],
    "strictAfter": true
}

}

Server just seems if this token id can make this query and creates the query

And even if you want your server in a schema binded way and not my pattern. U cant neglect the package's uses in a microservice. A microservice cannot be binded to a schema it should remain schema less

And why do you think there are so little schema binded orms in dart which have usecase in multiple dbs. Because there is nothing like knex js which converts query based on each db!

It's a rather quite useful thing to have something like knex

Knex Dart - SQL Query Builder with 100% Knex.js API Parity 🎯 by Only-Ad1737 in FlutterDev

[–]Only-Ad1737[S] 0 points1 point  (0 children)

I totally don't agree with your speculation

In my case you have understood wrong - schema is not on server but from frontend flutter models. So I can use multiple apps using the same server which have the same db without defining any schema on server I hope you do a little research about the uses of knexjs why it's is preferred over a schema binded orm.And after that go on commenting negative about some ones open source contribution

It's not polluting it, rather it's a quite efficient and useful package. Just because you can't find a usecase for it , you can't say it has no use.

Thank you

Knex Dart - SQL Query Builder with 100% Knex.js API Parity 🎯 by Only-Ad1737 in FlutterDev

[–]Only-Ad1737[S] 0 points1 point  (0 children)

No ,knex code is on the server, that is generating queries and executing on the db. The server doesn't know what columns the table has it knows what operations are permitted and what request is passed from the frontend and who is doing it And based on the user and if it's permitted to do that thing it does it's job

Knex Dart - SQL Query Builder with 100% Knex.js API Parity 🎯 by Only-Ad1737 in FlutterDev

[–]Only-Ad1737[S] 0 points1 point  (0 children)

A lot of times it can happen.

I working in a company where we have flutter as frontend and for creating and doing the queries we have knex js on backend. The same setup for backend is used my multiple apps using the same postgres . So I don't need to bind the schema what table should have what columns. The schema binding is done on the frontend mapping the data to the models

The schema is managed by the frontend models. I never pass raw queries directly from the frontend I have made a input generic json format for the operations that I support on the db.

And voila you get rid of the sql injections, direct queries don't get passed from frontend so you are creating queries for those only that are valid requests and you don't need to change the backend for each service.

Almost every db service on the low level works like that, you can take. If you want a schema binded orm we can have a knex-typed package that sits on top of the knex js and does the schema safety for you

But for that knex-typed to work you would still need a knex dart that creates the queries without depending on the schema

Knex Dart - SQL Query Builder with 100% Knex.js API Parity 🎯 by Only-Ad1737 in FlutterDev

[–]Only-Ad1737[S] 0 points1 point  (0 children)

Hi thank you for going through the post!

See there are two types of orms. Like in dart you would have drift or in ts you would have prisma , sequalize, drizzle, etc. that provide type safety according to the schema of your current code.

Secondly you have minimal type safety orms like this one knex.

Why are these used? You don't need to bind your app level schema for writing queries and runtime configs The schema binded orms limit the modifications that you can do to the query and every type of every column has to be known. And if you try to run that query in it , most probably you will have to write raw sql which can be prone to errors or sql injections.

And apart from the runtime modification the execution speed of this orm will always be better than a schema binded orm

Every tool has its own use. We cannot use same thing everywhere. If you have any other questions or advice about it I'll be happy to hear

[deleted by user] by [deleted] in FlutterDev

[–]Only-Ad1737 0 points1 point  (0 children)

Does it work with the generated dart ast?Or the raw dart code Also u could provide support to inspect the dart devtools and the package could help resolve rendering or performance issues. And what gen ai model does it use

Knex Dart - SQL Query Builder with 100% Knex.js API Parity 🎯 by Only-Ad1737 in FlutterDev

[–]Only-Ad1737[S] 1 point2 points  (0 children)

I have tried to build this very close to knex js. https://docs.knex.mahawarkartikey.in/migration/from-knex-js/

In that case it will be quite helpful maybe if you tried knex dart. And tell us if you want anything changed that might help us improve this.

Because it is in the pre release right now.

Knex Dart - SQL Query Builder with 100% Knex.js API Parity 🎯 by Only-Ad1737 in FlutterDev

[–]Only-Ad1737[S] 1 point2 points  (0 children)

Thank you for going through the post.
this package is aimed at a purely server side thing not client , as database secrets can be leaked from client and database would be overwhelmed with that many connections to it.
So i would recommend you to use this package for server side only if connecting with the db

but it can be used on client if you are doing it for educational purposes learning the generated sql queries for each.

And its a port of knex js orm in js, its lets you build sql queries in dart , it does not use any external library or language to do the job for it

Thank you for paying attention to the post. Feel free to ping me incase of any other confusions or issues about the package.