Giter VIP home page Giter VIP logo

kysely-orm's Introduction

Hi everyone :)

How to reach me

GoodModule

You can find the list of my open source projects ๐Ÿ‘‡

kysely-orm's People

Contributors

seeden avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

vasyas

kysely-orm's Issues

Hard-wired dependency on Postgres driver

Error: Cannot find module 'pg'
Require stack:
- /Users/vasyas/projects/ecofactor/bill/pkg/server/node_modules/kysely-orm/dist/cjs/Database.js
- /Users/vasyas/projects/ecofactor/bill/pkg/server/node_modules/kysely-orm/dist/cjs/index.js

However, I'm using MySQL.

No type info on model query find* response

Hi!

I've followed the steps in README.md but got an issue with the type of model query response.

Having the table types:

interface Users {
  id: Generated<number>;
  name: string;
  email: string;
}

interface DB {
  users: Users;
};

and the model defined:

export default class User extends db.model('users', 'id') {
  static findByEmail(email: string) {
    return this.findOne('email', email);
  }
}

My query doesn't have return type info, which is breaking type-safety in queries:

import User from "./User"

async function demo() {
  const user = await User.findByEmail("aa")
  console.log(user.aaa) // should fail here, b/c User doesn't have `aaa` field?
}

Sandbox with repo

Is this expected to be working?

Support compound keys

Though not a very big deal, but it would be nice to have a support for the compound table keys.

How about rewriting this to allow dependency injection?

I love what you've done here, but I find myself not wanting to use it because it doesn't allow dependency injection. Quite a bit of flexibility is lost by hardcoding repository behavior as static methods. For example, the code gets convoluted if we want a function that acts on any model conforming to a particular interface. Suppose I want to generically act on any of several similar tables? Or suppose I want to generically act on either of two databases? Or suppose I want to stub a table for testing purposes?

I've written several servers that rely on statics to access the underlying database, as you've done here, but I'm now finding that this is not how large scale applications are written. I recently decided to abandon this approach and do things the modern way.

Do you have any interest in rewriting this to put repository behavior on instance methods? I'd be glad to help or even do it all. This would require revising the approach to mixins.

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.