I'm building a desktop application using tauri, and I want to store data locally at the client using SurrealDB. I either want to store data on a specified path, or store the data in a similar way as IndexedDB stores data on the browser itself.
I would like to use the Javascript library that SurrealDB supplies, but there is no documentation regarding embedding, and instead it refers to the Javascript SDK.
I have never used databases like these before, therefore i currently lack knowledge regarding what is possible and how things are done regarding databases, but i am hoping to be able to read the database almost like a dead csv file (as there will only be one reader, the client), but with the query-language power of SurrealDB.
This is my current code, where i have issues in creating my database:
import Surreal from "surrealdb.js";
export const getSurrealClient = async () => {
// I will figure out a better path for deployment. Or
// the IndexedDB storing method will be used?
const db = new Surreal('file//:C:/Programmering');
await db.signin({
user: 'root',
pass: 'root'
});
await db.use({ns: 'namespace', db: 'mydb'});
return db
}
I get the following error message from the const db = new Surreal(...)
action:
Uncaught InvalidURLProvided: The provided string is either not a URL or is a URL but with an invalid protocol!
All in all, my general question is: How do i embed the database inside my tauri project and use the SurrealDB javascript library as the bridge between my project and database?