Git Product home page Git Product logo

Comments (4)

typeofweb avatar typeofweb commented on May 29, 2024 4

We discussed it further in private messages. I'll release 0.1v and then we can test and brainstorm.

from functional-orm.

typeofweb avatar typeofweb commented on May 29, 2024
  1. It's just an experiment to see if I was able to bend the type system to the extent I needed.
    In the end, my conclusion was that trying to keep it functional in TypeScript is really difficult and probably not worth it, and using a fluent-api (chaining) would be more beneficial and natural to most users.

  2. I didn't yet design the API, see answer AD 1. However, I was thinking of mimicking knex.js approach in this matter:

from(USER)
  .join(POST, [USER.columns.id, '=', COMMENT.columns.post_id])
  .select(USER.columns.id, COMMENT.columns.text)
  1. Yeah, definitely, querying the database is also a side-effect, so there isn't much difference here :)

  2. Yeah, definitely.

There are two main goals for now:

  • redesign the API to make it easier to reason about and type in a typesafe manner
  • write a script which works with PostgreSQL which generates typesafe models for the needs of this library

from functional-orm.

zaiste avatar zaiste commented on May 29, 2024

OK, that's great!

I'd also love to see a first-class support not only for tables, but also for views and materialized views along with other PostgreSQL specific features. For that reason, maybe we could use the table keyword in place of the from, so that we could then also use view etc.

Another idea would be to drop the execute and treat the pipe as the actual function i.e.

const query = pipe(
  table(Comment),
  join(Post), // Rails-like convention, otherwise it's needed to define the `on`
  select([Comment.id, Comment.content, Post.title]), // or variadic
);

const result = await query();

Just brainstorming here. There are some issues here, but hopefully this will eventually lead us to the correct solution. ;)

I also wonder if it will be possible to properly type the input for inserts in TypeScript...

from functional-orm.

zaiste avatar zaiste commented on May 29, 2024

@mmiszy I'm closing this as there's already a plan in place. We can discuss specific things in dedicated issues.

from functional-orm.

Related Issues (20)

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.