ravendb
Version:
RavenDB client for Node.js
56 lines • 1.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FromToken = void 0;
const QueryToken_js_1 = require("./QueryToken.js");
const index_js_1 = require("../../../Exceptions/index.js");
const StringUtil_js_1 = require("../../../Utility/StringUtil.js");
class FromToken extends QueryToken_js_1.QueryToken {
_collectionName;
_indexName;
_dynamic;
_alias;
get collection() {
return this._collectionName;
}
get indexName() {
return this._indexName;
}
get isDynamic() {
return this._dynamic;
}
alias() {
return this._alias;
}
constructor(indexName, collectionName, alias = null) {
super();
this._collectionName = collectionName;
this._indexName = indexName;
this._dynamic = !!collectionName;
this._alias = alias;
}
static create(indexName, collectionName, alias) {
return new FromToken(indexName, collectionName, alias);
}
static WHITE_SPACE_CHARS = [" ", "\t", "\r", "\n"];
writeTo(writer) {
if (!this._indexName && !this._collectionName) {
(0, index_js_1.throwError)("InvalidOperationException", "Either indexName or collectionName must be specified");
}
if (this._dynamic) {
writer.append("from '");
StringUtil_js_1.StringUtil.escapeString(writer, this._collectionName);
writer.append("'");
}
else {
writer
.append("from index '")
.append(this._indexName)
.append("'");
}
if (this._alias) {
writer.append(" as ").append(this._alias);
}
}
}
exports.FromToken = FromToken;
//# sourceMappingURL=FromToken.js.map