Files
genshin-world/assets/js/Classes/Store.js
2025-07-15 01:15:37 +02:00

98 lines
1.8 KiB
JavaScript

export class Store {
/** @private {string} */
#_storeName;
/** @private {boolean} */
#_autoIncrement;
/** @private {string|Array} */
#_keyPath;
/** @private {Object[]} */
#_indexes;
/**
* @param {string} storeName
* @param {boolean} autoIncrement
* @param {string|Array} keyPath
* @param {Object[]} indexes
*/
constructor(storeName, autoIncrement = true, keyPath = "id", indexes = []) {
this.#_storeName = storeName;
this.#_autoIncrement = autoIncrement;
this.#_keyPath = keyPath;
this.#_indexes = indexes;
}
get storeName() {
return this.#_storeName;
}
set storeName(value) {
this.#_storeName = value
}
get autoIncrement() {
return this.#_autoIncrement;
}
set autoIncrement(value) {
this.#_autoIncrement = value
}
get keyPath() {
return this.#_keyPath;
}
set keyPath(value) {
this.#_keyPath = value
}
get indexes() {
return this.#_indexes;
}
set indexes(value) {
this.#_indexes = value
}
}
export class Index {
/** @private {string} */
#_name;
/** @private {string} */
#_keyPath;
/** @private {Object} */
#_options = {};
/**
* @param {string} keyPath
* @param {boolean} isUnique
*/
constructor(keyPath, isUnique = false) {
this.#_name = keyPath;
this.#_keyPath = keyPath;
this.#_options = { unique: isUnique};
}
get name() {
return this.#_name;
}
set name(value) {
this.#_name = value;
}
get keyPath() {
return this.#_keyPath;
}
set keyPath(value) {
this.#_keyPath = value;
}
get options() {
return this.#_options;
}
set options(value) {
this.#_options = value;
}
}