const Surreal = require("surrealdb.js");

const db = new Surreal("https://baas.microservices.al/rpc");
async function main() {
  try {
    await db.use("fluxem", "fluxem");

    const token = await db.signin({
      NS: "fluxem",
      DB: "fluxem",
      SC: "allusers",
      email: "test@acme.com",
      pass: "some password",
      marketing: true,
      tags: ["rust", "golang", "javascript"],
    });

    let created = await db.create("person", {
      title: "Founder & CEO",
      name: {
        first: "Tobie",
        last: "Morgan Hitchcock",
      },
      marketing: true,
      identifier: Math.random().toString(36).substr(2, 10),
    });

    // await db.invalidate();

    // const res = await db.authenticate(token)
    console.log("token", created);
  } catch (e) {
    console.error("ERROR", e);
  }
}

main();
