Comments (4)
We discussed it further in private messages. I'll release 0.1v and then we can test and brainstorm.
from functional-orm.
-
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. -
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)
-
Yeah, definitely, querying the database is also a side-effect, so there isn't much difference here :)
-
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.
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 insert
s in TypeScript...
from functional-orm.
@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)
- Add Greenkeeper
- Add TravisCI
- Add CI Badge
- Add README
- Add License
- Generate models from database HOT 1
- Add docker with PostgreSQL for tests
- Add tests
- Implement simple queries HOT 1
- Support BigInt
- Support array types in postgres
- Refactor connection create
- Support LIMIT clause
- Support multiple WHERE
- Add mock tables and data
- Read schema from database
- Support nested WHERE clauses
- Support shorthand where definitions
- Action required: Greenkeeper could not be activated 🚨
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from functional-orm.