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

Storing Usernames

Below you can find examples in js and ts of how to storing usernames and names, and checking if a username exists

JavaScript

(async() => {
const AbcDB = require("abc.db");
const DB = new AbcDB("mongo string", "data");
const UserDB = DB.Collection("users");
const data = {
    username: "user_name",
    name: "User Name"
}
if (UserDB.has(data.username) return console.log("User already exists");
await UserDB.set(data.username, data);
})();

TypeScript

import AbcDB from "abc.db";
(async() => {
const DB = new AbcDB("mongo string");
const UserDB = DB.Collection("users", "data");
const data: <{username: string, name: string}> = {
    username: "user_name",
    name: "User Name"
}
if (UserDB.has(data.username)) return console.log("User already exists");
await UserDB.set(data.username, data);
})();
PreviousUser Info

Last updated 4 years ago

Was this helpful?