Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
C0D4669022yYou can take the data returned and put it into localStorage, if the query is executed clientside, it also means the connection is made clientside. You sir, just gave your database away to anyone that wants it.
-
You do have things like IndexedDB but that's pretty low level. There are a bunch of higher level libraries which you can find at the bottom of this article.
https://developer.mozilla.org/en-US... -
Hazarth95192yWhat would be the usecase and why not just store what you need in local storage in a json format.
I mean there already exist completely offline websites like devdocs.io, everything is downloaded into memory and lives there until the browser purges it (which happens after certain amount of days automatically by the way)
I don't see the need for a Client side query language in the browser right now, any ideas? -
kamen69252yI think you're looking for GraphQL. I don't have much experience with it, but from what I know it's close to what you're after.
-
There are embeddable databases, e.g. LevelDB / LowDb / ...
GrqphQL is an entirely different thing @kamon ...
The thing with embeddable databases is: It's not an database, at least not in JavaScript.
Sounds weird?
Don't forget that JavaScript is single threaded....
I'm not entirely sure how LevelDb or other stuff works, so I might be off the charts wrong - but the thing that makes a database _wroom wroom_ (and sadly very complex) is heavy threading.
That's a thing that does not exist in JS. -
@dotenvironment are you asking for like a "JSQL" thing, where if the data in question is client-side, perhaps a class or object imported from a JS/TS file and you want to query it SQL-style? Or is this about if you're already fetching from an API and you want to query on the response? either way, I don't know of any JS libraries that operate like SQL to query JSON. It's not insane, but I do wonder about its use case like others have said. map/filter/reduce can do a lot of heavy lifting after fetch 🤔
-
Grumm18232yNot sure what kind of data you want to store in the 'client-database'.
Also note that you will have zero control over the data. It will not be saved or anything.
If the use-case is just here is an empty list, you fill it up with whatever the client wants, store all that in a table in the IndexedDB.
But if the client clears all of his cache and site data, all of that is gone. No backups or ways to get that data back.
(that is why all databases are in the cloud) -
hmm the all comments here seem to correctly indicate that adding data on client side is neither secure and nor guaranteed to live indefinitely. i guess all the data i need can be stored in js objects/ json files to be used , filtered and accessed accordingly
thanks for the discussion, everyone
So i have been thinking..
SQL is a lang that runs on a specific software on the server, and helps creating data stores(databases and tables) that can be queried & manipulated.
is there a way to run sql like queries on the client side with no interaction from backend at all?
Say i have 5 inter related data models. in a backend world, they will form nice little tables of a db with all their joins and composite keys. from the server, i shall be querying them like "SELECT name from x where y=z & ..."
but what if i could store them like tables in browser memory and run the same query filters via a query language... is this possible?
i know this poses a certain security risk, but we already use cookies, local storage and a lot of json based shitty client side storages. surely it might be possible to have a lesser optimised sql tables on the frontend with extremely good querying capabilities?
or am i talking something far fetched here?
question