UNPKG

630 BJavaScriptView Raw
1/**
2 * @copyright Copyright (c) 2019 Maxim Khorin <maksimovichu@gmail.com>
3 */
4'use strict';
5
6module.exports = class Expression {
7
8 constructor (value, params) {
9 this.value = value;
10 this.params = params;
11 }
12
13 get (db) {
14 if (this._value === undefined) {
15 this._value = this.value;
16 if (this.params) {
17 for (const key of Object.keys(this.params)) {
18 this._value = this._value.replace(new RegExp(`:${key}`, 'g'), db.escape(this.params[key]));
19 }
20 }
21 }
22 return this._value;
23 }
24};
\No newline at end of file