UNPKG

@brontosaurus/db

Version:
56 lines (55 loc) 2.87 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAccountByUsernameAndNamespaceDomain = exports.getAccountByUsernameAndNamespaceName = exports.getAccountNamespaceMatchByUsernameAndNamespace = void 0; const match_1 = require("../data/match"); const account_1 = require("./account"); const namespace_1 = require("./namespace"); const getAccountNamespaceMatchByUsernameAndNamespace = (username, namespace) => __awaiter(void 0, void 0, void 0, function* () { const namespaceInstance = yield namespace_1.getNamespaceByNamespace(namespace); if (!namespaceInstance) { return { succeed: false, reason: match_1.MATCH_FAILS_REASON.NAMESPACE_NOT_FOUND, }; } const account = yield account_1.getAccountByUsernameAndNamespace(username, namespaceInstance._id); if (!account) { return { succeed: false, reason: match_1.MATCH_FAILS_REASON.ACCOUNT_NOT_FOUND, }; } return { succeed: true, account, namespace: namespaceInstance, }; }); exports.getAccountNamespaceMatchByUsernameAndNamespace = getAccountNamespaceMatchByUsernameAndNamespace; const getAccountByUsernameAndNamespaceName = (username, namespace) => __awaiter(void 0, void 0, void 0, function* () { const namespaceInstance = yield namespace_1.getNamespaceByNamespace(namespace); if (!namespaceInstance) { return null; } const account = yield account_1.getAccountByUsernameAndNamespace(username, namespaceInstance._id); return account; }); exports.getAccountByUsernameAndNamespaceName = getAccountByUsernameAndNamespaceName; const getAccountByUsernameAndNamespaceDomain = (username, domain) => __awaiter(void 0, void 0, void 0, function* () { const namespaceInstance = yield namespace_1.getNamespaceByDomain(domain); if (!namespaceInstance) { return null; } const account = yield account_1.getAccountByUsernameAndNamespace(username, namespaceInstance._id); return account; }); exports.getAccountByUsernameAndNamespaceDomain = getAccountByUsernameAndNamespaceDomain;