Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Ilan Copelyn
    @ilanc
    @elhigu thanks for the info!
    Nail Rode
    @NailRode
    Hi guys, whats the purpose of knex migration source ?
    I'm using Nrwl nx, which uses webpack under the hood to bundle my backend
    Mikael Lepistö
    @elhigu
    to make possible to use webpack etc. for storing migrations instead of scanning directory contents
    so it removes so that knex is not dependent on file system
    kharchenkoS
    @kharchenkoS
    hi, could some one helps db.select(db.raw('structured_address->>neighbourhood')) .from(dbConfig.tableNames.bulletins) .groupByRaw('structured_address->>"neighbourhood"')
    error: select structured_address->>neighbourhood from "bulletinsf2e5f6bd6f371db3f0fc12b482bbac7f" group by structured_address->>"neighbourhood" limit $1 - column "neighbourhood" does not exist
    some problem i guess in select(db.raw('structured_address->>neighbourhood'))
    kharchenkoS
    @kharchenkoS
    i found should be "structured_address->>'neighbourhood'"
    Nail Rode
    @NailRode

    @elhigu Ok, but when i use:
    knex.migrate.latest({
    migrationSource: new WebpackMigrationSource(require.context('./migrations', false, /.ts$/))
    })

    i have to place my migrations under ./migrations in my build directory.
    Webpack is not bundling the migrations.

    ENOENT: no such file or directory, scandir '/Users/nail/Entwicklung/Projekte/steute/sensorBridgeNx/dist/apps/backend/migrations'
    there is test for the resolver... I have never used it myself
    Nail Rode
    @NailRode
    Thanks, i will have a look into it :)
    Mikael Lepistö
    @elhigu
    and I'm sure somewhere in issues there is some example code how to write own migration source implementation
    I thought cookbook in the wiki would have one, but I didn't find anything there :|
    Nail Rode
    @NailRode
    That was also my problem. The documentation could be improved x.x
    Mikael Lepistö
    @elhigu
    Would you like to write an entry to knex's github Wiki's cookbook? would be helpful.
    Nail Rode
    @NailRode
    Of course I can do that, if i solve the issue :)
    Mikael Lepistö
    @elhigu
    awesome, thanks :)
    Nail Rode
    @NailRode
    @elhigu , it was an issue with the version i was using: 0.15.2 was not working as a
    expected*
    i upgraded to the latest version and migrations are now bundled successfully.
    prog20901
    @prog20901
    Which browser supports 120 MB html file? I want to open an html file which is about 120 MB. please advise. Chrome crashes.
    Mikael Lepistö
    @elhigu
    links and lynx browsers should be able to open that just fine
    Mohammad Hadi Aliakbar
    @mohaalak
    I'v got a question, how do you get a nested object from a query with left joins? is there a good way for it? I don't like this bloated ORM
    Mikael Lepistö
    @elhigu

    is there a good way for it?

    Use ORM

    for example objection.js is not bloated
    Copot Matei
    @towc
    hey all, I'm trying to get items between certain hours, in a certain date range. For example, every item with a datetime between 9-15 in the second week of march 2019. What's an elegant way to do this?
    postgres is the underlying implementation
    My first thought was to store date and time separately, and match with 2 wheres, but it seems like there might be a simpler way
    I shouldn't have to add extra columns because of a knex limitation, right? I could knex.raw, but that's the opposite of elegant
    Mohammad Hadi Aliakbar
    @mohaalak
    @elhigu so I did not like that ORMs I write a little module that will get nested objects with types https://github.com/mohaalak/nested-knex
    Mikael Lepistö
    @elhigu
    @mohaalak from that API it looks like that next you will start refactoring those nested type sets and corresponding joins somewhere together for queries that you are doing often to prevent copy-pasting the same code to many places... at that point you have written your own MVP ORM :) Also I cannot really agree with those claims that packages readme is saying about ORMs, but I hope that your query result dewrapper suits your needs good enough. Btw. there are some other libraries that are already doing that kind of nesting joined data to nested objects, but I cannot remember the names anymore.
    Mohammad Hadi Aliakbar
    @mohaalak
    @elhigu I think you are talking about NestHydration that this library use it too, the problem that I have with ORMs is that they build SQL queries for you that's something that bothers me a lot, and about nested types right now you can just extract it and name it whatever you want and use it multiple times, but that's just creating select they cannot create query for you and I don't think that I will I'm happy to build my queries.
    Mikael Lepistö
    @elhigu

    they build SQL queries for you

    objectionjs doesn't build any queries for you if you don't want to. It uses knex for building queries. Only if you specially choose to ask for related data it will build needed joins / multiple queries automatically (many times doing multiple queries instead of joins is more performant).

    you can just extract it and name it whatever you want and use it multiple time

    Then it is pretty much like relation declaration.

    Mikael Lepistö
    @elhigu

    , but that's just creating select they cannot create query for you and I don't think that I will I'm happy to build my queries.

    That return type declaration is tightly coupled with the query which for it was created... so you actually need store both somewhere for effectively reuse the type... so... it sounds like manually done one-off relation declaration with possibly some filtering (supporting only reading data, for example inserting nested data would't work)..

    anyways if you need only that one feature of nesting read data then your library is perfect for you :)
    Copot Matei
    @towc
    Hey again, I have a date and time column (of the respective type) in pg. How do I check if the resulting timestamp (date+time) is between two values?
    I'm guessing I would need to alias a subquery, but I'm quite confused
    and that it would involve at least a raw portion of the query, for constructing date+time
    well, this works: .whereRaw('date+time >= ? AND date+time <= ?', [from, to])
    would still hope there's a more elegant version
    Mohammad Hadi Aliakbar
    @mohaalak
    @elhigu a big problem that I have with objection.js, that is designed around active record pattern, active record pattern is hard to test, and if you need to change the ORM it will be hard to do so but if it had a repository pattern that was something else
    Mikael Lepistö
    @elhigu
    :D it is not designed around active record pattern (even that it might look like it)
    Also changing ORM is never easy in practise during my 20 years career I have done it just couple of times and it has always involved complete rewrite of the old system
    Mikael Lepistö
    @elhigu
    I usually write code even with objection in kind of dependency injection style, where I have service APIs doing business logic operations, which are pretty easy units to tests and most of the time I test also that that those service APIs works until DB level. If there are some other internal parts in those service APIs, then I might unit test smaller parts separately if necessary...
    that actually look a bit like a repository pattern...
    Mikael Lepistö
    @elhigu
    I would be happy to see some examples what is so hard to do with it... I'm really having hard time to understand that critic that just says that its design patter is bad. Origins of objection is that it was not really designed through patterns, but through actual use cases during our company's internal app development. We found out many things/helpers which were good fit to our style of development and which were later on polished and wrapped to a separate public npm module. Also hatred towards Hibernate had its own effect to design of objection :D