UNPKG

1.05 kBJavaScriptView Raw
1"use strict";
2/*
3 * @adonisjs/lucid
4 *
5 * (c) Harminder Virk <virk@adonisjs.com>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10Object.defineProperty(exports, "__esModule", { value: true });
11exports.ModelKeys = void 0;
12/**
13 * Exposes the API to collect, get and resolve model keys
14 */
15class ModelKeys {
16 constructor(keys = {}) {
17 Object.defineProperty(this, "keys", {
18 enumerable: true,
19 configurable: true,
20 writable: true,
21 value: keys
22 });
23 }
24 /**
25 * Add a new key
26 */
27 add(key, value) {
28 this.keys[key] = value;
29 }
30 get(key, defaultValue) {
31 return this.keys[key] || defaultValue;
32 }
33 /**
34 * Resolve key, if unable to resolve, the key will be
35 * returned as it is.
36 */
37 resolve(key) {
38 return this.get(key, key);
39 }
40 /**
41 * Return all keys
42 */
43 all() {
44 return this.keys;
45 }
46}
47exports.ModelKeys = ModelKeys;