#Im going to open a thread so we dont

1 messages ยท Page 1 of 1 (latest)

fair owl
#

@dull oyster

dull oyster
#

If you want to 'save' your queries somewhere, save it in state... on the file system. If you want it to be cross device you need to store it on the backend.

fair owl
#

Okay so here is the issue, i dont want to save them

#

BUT

#

i want a way to save the state of the query, abd the data returned in nextjs

#

because these are stuff you dont need to save

#

specially the data itself, you can export to csv at that point

dull oyster
#

I mean its still the same answer.

#

save the state into a file.

#

You want to save the state after navigations and re-renders right?

#

save it to a file, pick a schema, pick json, ini, endless possibilities

fair owl
#

But is that necessarily efficient

dull oyster
#

I would not use zustand or tsq.

#

Its the most simple, and efficient way to do it. A library is going to cost more than reading and writing to a local file

#

if your plan is to be on device only.

#

but also... again.... you shouldnt use nextjs. it isnt supported in electron apps

#

it works, but there are issues.

#

weird issues, your not going to get much help with

#

ive tried lol

fair owl
#

Its not build in electron

#

its buillt in tauri which supports nextjs

dull oyster
#

Okay, okay. good.

#

So why is useState not good enough here?

#

based on your diagram?

fair owl
fair owl
dull oyster
#

Mhmmmm.

fair owl
#

what would you then?

#

You dont need to save it in the system, because the user can look at this query for 1 sec and be like nahh i dont need this

#

so this is all temporary kinda

dull oyster
#

You either need backend pagination, or you display it on the front end. I regularly fetch and display 100k records.

#

easily

#

virtual pagination

fair owl
#

so as he scrolles, i get more and more ?

dull oyster
#

Thats one way to do it.

#

or pages.

fair owl
#

Alright, so im sending ove3r another diagram

dull oyster
#

okay.

#

id highly recommend tanstack table

#

its amazing

fair owl
#

Real current project view for visualization so you can see clearer

dull oyster
#

So. in my opinion.

#

Tree view, should be the master component.

#

that takes up the page.

#

With the sql query editor and query results within it.

#

query editor and results dont need to share state.

fair owl
#

so can you hop on a call so i can understand better ?

dull oyster
#

I cant, im at work lol

fair owl
#

lmao

dull oyster
#

well not 'at work' but in a work call

fair owl
#

i see

#

okay can you go on with your opinions ?

#

|-- /src
| |-- /components
| | |-- Header.js
| | |-- Sidebar.js
| | |-- DatabaseList.js
| | |-- TableView.js
| | |-- QueryRunner.js
| | |-- ...other components
| |
| |-- /pages
| | |-- index.js
| | |-- databases.js
| | |-- queries.js
| |
| |-- /state
| | |-- useDatabaseStore.js
| | |-- useQueryStore.js

i was thinkign something like this but tsx

dull oyster
#

sec.

#

writing up some pseduo

fair owl
#

aight

dull oyster
#
export default function Home() {
  const [db, setDb] = useState(null);
  const setDb = (database) => {
    setDb(database);
  }

  return (
    <Layout>
      <DBExplorer setter={setDb} database={db}>
        Tree view here
      </DBExplorer>
      <QueryEditor database={db} >
        <QueryResults />
      </QueryEditor>
    </Layout>
  );
}
#

this is rough

#

but db is the only thing you need to share between dbexplorer and query editor

#

so you share it by hoisting the state to the parent

#

and exposing the setter to the db explorer and value to the editor

fair owl
#

The db is shared by default, since i can call it from wherever i want i nmy app

dull oyster
#

Sure, is your setter shared?

fair owl
#

Its coming through some custom invoke code

dull oyster
#

right but thats whats populating the tree view right?

fair owl
#

This is an example

dull oyster
#

Oh goodness lol

#

๐Ÿ˜‚

#

What your doing isnt a bad way to do it I guess. lol but its different than I would do it

fair owl
#

Its the way i can access the backend in tauri

dull oyster
#

I gotcha, im not familiar with it really

fair owl
#

i see

#

rn, i turn it into a fixed model just to get something to displayt

#

this was done in like 2 hours so

dull oyster
#

But regardless. you really need to store the data 'globally' for the page

fair owl
#

Its still verrry early

dull oyster
#

If your not in a rush I can help you out more after work.

#

Like work up something a little more concise

#

Did you look at that react query builder library? I think its perfect for something like this.

fair owl
#

Sure thing

#

how long do you need to see if i would be awake

#

i'll check it right now

dull oyster
#

Where you from? Just curious

fair owl
#

Middle east

dull oyster
#

Your english is good if your not native

#

gotcha

fair owl
#

Oh yeah, i got a slight accent thoug

#

wby ?

dull oyster
#

US, florida to be specific

fair owl
#

Ah damn

#

You need like 4-5 hours to get out of work no ?

dull oyster
#

2 more hours till work is done, but ill be up till like 2-3 am its friday lol

#

so if your going to bed its all good

fair owl
#

nah

dull oyster
#

ill add you so we can take to dms

fair owl
#

Its 9:30

#

ill be awake in 2 hours

#

its friday ๐Ÿ˜‚

dull oyster
#

Whats your background btw.

#

you proficient with js?

fair owl
dull oyster
#

Okay so you know what your doing, not trying to peice this together from nothing

#

which isnt a bad thing, it just changes how ill explain things

fair owl
#

yessir

#

im a developer by profession

dull oyster
#

kk yeah after im done with this meeting ill get something together to better show what I mean

fair owl
#

But its my first big nextjs project, so i need someone to roughly guide me

dull oyster
#

honestly you should treat this as a react project and not worry about the nuances of nextjs until they are relevant.

fair owl
#

yeah i dont really use react at work, so i dont know the best practices there either

dull oyster
#

Gotcha, thats important for me to know ๐Ÿ˜„

fair owl
#

yessir

#

Alright ill be looking forward for your message

dull oyster
#

np accdept my friend request

fair owl
#

i can give you a deeper overview of the project

dull oyster
#

ill probably meessage you there

#

itll be easier

fair owl
#

sure thing

dull oyster
#

or you can open a help forum thread, thats technically where it should go ๐Ÿ˜›

#

but idk how much you want to share publicly

fair owl
#

honestly prefer one person helping, and i dont like to share too much of the code rn

dull oyster
#

gotcha

#

I figured.

#

dms easier

fair owl
#

been in too many situations where the people trying to help me themselves cannot agree on a common gtround

#

yessir

dull oyster
#

Well... theres no one way to do something

fair owl
#

im open to have someone on board as a developer in case you liked the idae

dull oyster
#

Meh, maybe. We will see, its interesting for now xD I have a job hahah