powersync-js icon indicating copy to clipboard operation
powersync-js copied to clipboard

Improve JS docs with one example with Kysely syntax

Open guillempuche opened this issue 1 year ago • 5 comments

https://docs.powersync.com/client-sdk-references/js-web#using-powersync-crud-functions

Apart from showing SQL syntax, show Kysely syntax, e.g.useQuery(kysely.selectFrom...)

guillempuche avatar Aug 20 '24 11:08 guillempuche

That's a good suggestion, thanks! We can add the Kysely equivalent to the examples.

benitav avatar Aug 22 '24 07:08 benitav

How would you transform this

https://github.com/guillempuche/localfirst_react_server/blob/d383ab33a01ffff866d5324dada0e6678c3bc0c6/apps/web/src/pages/page_home.effect.tsx#L9 to dbEffect.selectFrom..., imatge

Right now, I use dbEffect for updating https://github.com/guillempuche/localfirst_react_server/blob/d383ab33a01ffff866d5324dada0e6678c3bc0c6/apps/web/src/components/editor.effect.tsx#L43


Discord thread https://discord.com/channels/1138230179878154300/1266491006593798165/1276214618217386035

guillempuche avatar Aug 22 '24 16:08 guillempuche

I haven't run it, but it compiles: https://github.com/guillempuche/localfirst_react_server/blob/a1295f7e773cdc99c091881292c67fa7980d15a3/apps/web/src/pages/page_home.tsx#L8-L12

guillempuche avatar Aug 22 '24 19:08 guillempuche

Just to close the loop here: Looks like you got this to work, if I follow the Discord thread?

const watchQuotes = useQuery<QuoteQuery>(
        'SELECT * FROM quotes ORDER BY id DESC',
    )
    const watchQuotesEffect = useQuery(
        dbEffect.selectFrom('quotes').orderBy('id', 'desc').selectAll(),
    )

benitav avatar Aug 27 '24 08:08 benitav

Yes, i did

guillempuche avatar Aug 27 '24 10:08 guillempuche