A small test project to try out SurrealDB with Typescript. In the DB we will have a User table with a few entries. We will have a frontend in which we use the sdk in order to authenticate and read the user entries.
With SurrealDB installed Let's start out with a on-disk test database with a single root user.
surreal start --user root --pass root rocksdb:/home/david/typescript_surrealdb_test/ts_test.db
Now in our TypeScript project let's install the surrealdb sdk.
npm i surrealdb
In the Surrealist GUI we create a schemaless table user with two fields: first_name and last_name. And we create two entries for that table each with a randomly generated id.
Running our vite development server
npm run dev
Loading our page in the browser returns the stringified entries from our User table.
[ { "first_name": "test2", "id": "User:svtic3xqkr5r50ea3sad", "last_name": "user" }, { "first_name": "test", "id": "User:znrhq8hubryi8tivxm3s", "last_name": "user" } ]
Now this was quite painless. Nice.