by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Mikael Lepistö
    @elhigu
    @NomadXD I would use just plain knex/objection partial raw queries
    But I wouldn't do that query as a loop, but would just do single query that select all hospitals nearest to that position (limited with maximum radius), order them by distance or something like that. It is easier to avoid using stored procedures with knex / objection unless there are some real performance issues that requires them.
    Lahiru Udayanga
    @NomadXD
    @elhigu Thanks. But I just want to make sure that I get atleast one hospital as the result. If I give a one static radius then I can't make sure I get a hospital every time. Actually I'm doing the same thing like you said but if I dont get a result, then I increase the search radius
    Mikael Lepistö
    @elhigu
    So wouldn't it be then the same to search with radius that covers all world, order by distance and limit result to for example 100 nearest or so? I mean if that radius limit is meant to make query faster, because there are less hospitals to check I don't thing it helps at all. AFAIK to know if each hospital is near to that point, PG still have to calculate the distance between that point and hospital location for ALL hospitals in the table.
    Mikael Lepistö
    @elhigu
    Maybe one way to make that kind of query fast is for example to decide that world has 1000-10000 hospital clusters and each cluster has their center and radius. Then you can more easy limit the results so that accurate distance calculation is done only for those hospitals, which belongs to nearest clusters. But if there is only less than 100k hospitals to check that kind of clustering might not be necessary... Also there probably is some better ways to do that optimization (maybe postgis has some special graph index for that which allows to do rough checking automatically for limiting results) so that clustering is not necessary for even huge amount of hospitals.
    Enmanuel Durán
    @enmanuelduran
    Hi knex community, very nice to be part of it.

    I have been struggling lately with a situation on knex, can I get a hand? I posted the issue on SO but no-one has helped so far.

    https://stackoverflow.com/questions/62338510/knex-bulk-insert-not-waiting-for-it-to-finish-before-passing-to-the-next-async-o

    async function service() {
        await createElements(list); // insert x elements from the list
        const elements = await getLastXInsertedElements(userId, list.length)
        await useElementsIdAsForeignKey(listMakingUseOfElementsIds);
    }
    I basically have some code that looks similar to the one above, but when I get the elements it does not always contain the complete list of elements that was just inserted, that leads me to believe that for some reason knex does not return when the operation has finished but rather when the operation started (when the bulk insert started)
    if you want to see what is behind those functions, you can check the SO link
    François Romain
    @francoisromain
    Hello all. We use knex-db-manager to run tests. The populateDb function seeds the database with all seed files in parallel, which creates error when there are constraints. Is it possible to make it work like knex’s own seed function which run seed files in order?
    We just opened a PR about this: Vincit/knex-db-manager#89
    @elhigu what do you think about it?
    Mikael Lepistö
    @elhigu
    actually I was just looking the PR. I didn't even know that it did ran those parallel currently. sequential running definitely makes sense.
    François Romain
    @francoisromain
    ok cool. Thank you
    dsauerbrun
    @dsauerbrun
    hi all... I'm killing myself here trying to get migrations working with typescript... none of my imports in my knexfile work when my tsconfig.js module is "es2020"; however, if i change the tsconfig.js module to "commonjs" the imports work just fine... here is a gist of my setup as well as some console logs showing what i mean(connectionProperties in line 5 from knexfile.ts is showing up undefined)
    dsauerbrun
    @dsauerbrun
    nvm... found this TS_NODE_COMPILER_OPTIONS='{ "module": "commonjs" }' knex migrate:latest
    Kristjan
    @KristjanTammekivi
    Btw have you guys talked about starting migrating to typescript?
    Mikael Lepistö
    @elhigu
    no
    Kristjan
    @KristjanTammekivi
    Any chance of that happening?
    Mikael Lepistö
    @elhigu
    it would require pretty much complete rewrite + I don't see much benefit in that. Others might have different opinions though.
    Kristjan
    @KristjanTammekivi
    I think it's possible to do it piece by piece
    Complete rewrite....uhhhh....knex is way too big and complex
    Mikael Lepistö
    @elhigu

    Complete rewrite....uhhhh....knex is way too big and complex

    I don't see it impossible... there is lots of stuff that could be deprecated and internals should be done in a different manner anyways (having internal AST of built query to be able to inspect and modify it easier).

    Knex actually is not so complex either... or at least it shouldn't be. It should be really straight forward set of APIs that construct AST and compiler plugins, which build DB specific queries from that AST :sweat_smile:
    Kristjan
    @KristjanTammekivi
    Maybe it's because I'm not overly familiar with the source code
    Mikael Lepistö
    @elhigu
    But I would be worried that actually having typescript implementation would make development more difficult
    Kristjan
    @KristjanTammekivi
    Every time I go through it I just see stuff passed around
    Mikael Lepistö
    @elhigu
    since it gives a big headaches time to time
    Kristjan
    @KristjanTammekivi
    I would disagree, saying it would make more easier to develop
    But I do have several years of typescript behind me, I can't really remember how difficult to learning curve was
    Mikael Lepistö
    @elhigu
    Also less people knows typescript so less accessible for contributors
    Kristjan
    @KristjanTammekivi
    There's the trade-off between knowing typescript and understanding what some variables have / where something is being passed in from, etc
    With typescript you'll know what properties you have, for instance
    Mikael Lepistö
    @elhigu

    But I do have several years of typescript behind me, I can't really remember how difficult to learning curve was

    IIRC it wasn't so hard, but some stuff is just hard to do like having plugin interfaces extending existing APIs

    Kristjan
    @KristjanTammekivi
    Not sure if contributors would have to do it
    Mikael Lepistö
    @elhigu
    With more straightforward and cleaner codebase knowing better what is passed around would also be easier with plain JS
    Kristjan
    @KristjanTammekivi
    Oh, definitely
    Is there a public roadmap I could take a look at?
    Or are you guys just winging it
    Mikael Lepistö
    @elhigu
    But generally I'm not against typescript especially with end application code I am just not sure if it would be beneficial with knex or not. Maybe it would. Though also from objection we know that trying to type query builder return value depending on builder chain is really tricky
    Kristjan
    @KristjanTammekivi
    The current typings knex has are pretty neat
    I'm blanking on his username, but who made it did a good job with the generics
    Mikael Lepistö
    @elhigu
    I think the gituser was @lorefnon who took that part of knex under his wing
    Kristjan
    @KristjanTammekivi
    Sounds about right
    Yeah that was him
    issa marie tseng
    @issa-tseng
    i'm.. having the absolute worst time getting the tests to run, even just for postgres. i'm just trying to follow the instructions in the CONTRIBUTING file but i can't seem to get the tests to actually talk to the databases
    issa marie tseng
    @issa-tseng
    there also appears to be some kind of require path issue for knex.js when invoking cli.js?
    Harish Karumuthil
    @harish2704
    Hi, I think the Travis CI pipeline seems to be broken now. Please see https://travis-ci.org/github/knex/knex/jobs/702942826
    Hélène Martin
    @lognaturel
    Hey folks and thanks for the work you've put into knex! I collaborate with @issa-tseng and wanted to give a little context for how the bug fixed at knex/knex#3900 manifests for our project. We work on ODK, a set of open source tools for data collection in resource-constrained environments (https://github.com/getodk/central-backend is the component that uses knex). The deep dive @issa-tseng documented on the issue came out of the connection leak leading to failures for a field partner doing COVID-19 contract tracing in Subsaharan Africa. All this to say that this is a case where code review can have big positive impact!