User Info
An example of storing user info
Below you can find examples in js and ts of how to store basic user info using abc.db. I have used hard coded users but you probably wouldn't.
JavaScript:
(async() => {
const AbcDB = require("abc.db");
const DB = new AbcDB("mongo string", "data");
const UserDB = DB.Collection("users");
const users = [
{
name: "John Smith",
age: 23,
email: "[email protected]"
},
{
name: "Amanda Baker",
age: 32,
email: "[email protected]"
}
];
for (const user in users) {
await UserDB.set(user.email, user);
}
const user = await UserDB.get("[email protected]");
})();
TypeScript
import AbcDB from "abc.db";
(async() => {
interface User {
name: string;
age: number;
email: string;
}
const DB = new AbcDB("mongo string", "data");
const UserDB = DB.Collection("users");
const users: Array<User> = [
{
name: "John Smith",
age: 23,
email: "[email protected]"
},
{
name: "Amanda Baker",
age: 32,
email: "[email protected]"
}
];
for (const user in users) {
await UserDB.set(user.email, user);
}
const user: User = await UserDB.get("[email protected]");
})();
Last updated
Was this helpful?