abc.db
  • Home
  • Documentation
    • Main Class
    • Collections
  • Examples
    • Examples
    • Moving from Quick.DB
    • Moving from version 1 to 2
    • User Info
    • Storing Usernames
  • Links
  • NPM Page
  • Source Code
  • Support Server
Powered by GitBook
On this page
  • JavaScript:
  • TypeScript

Was this helpful?

  1. Examples

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: "john.smith@email.com"
    },
    {
        name: "Amanda Baker",
        age: 32,
        email: "a.baker@anotheremail.com"
    }
];
for (const user in users) {
    await UserDB.set(user.email, user);
}
const user = await UserDB.get("john.smith@email.com");
})();

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: "john.smith@email.com"
    },
    {
        name: "Amanda Baker",
        age: 32,
        email: "a.baker@anotheremail.com"
    }
];
for (const user in users) {
    await UserDB.set(user.email, user);
}
const user: User = await UserDB.get("john.smith@email.com");
})();
PreviousMoving from version 1 to 2NextStoring Usernames

Last updated 4 years ago

Was this helpful?