Public vals
14
joey
BlobArray
Script
Blob Array Create an array as a Database, instantly! Just create a new val for your array: import { BlobArray } from "https://esm.town/v/joey/BlobArray";
type User = { email: string };
// specify the type inside the TS generic <> to define the type of your array
export let myUserArray = BlobArray<User>("my-user-array"); Now import it and start using it in your vals! import { myUserArray } from "https://esm.town/v/joey/myUserArray";
// overwrite the entire array
await myUserArray.set([{ email: "user1@gmail.com" }, { email: "user2@yahoo.com" }]);
// get all the entries in your array
const allUsers = await myUserArray.get();
// call any array method you want, just use "await"
await myUserArray.push({ email: "johndoe@gmail.com" });
const gmailUsers = await myUserArray.filter(u => u.email.includes("@gmail.com"));
0