@ultipa-graph/ultipa-node-sdk
Version:
NodeJS SDK for ultipa-server 4.0
242 lines • 8.91 kB
JavaScript
"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.IndexExtra = void 0;
const connection_base_1 = require("./connection.base");
const types_1 = require("../../types");
const utils_1 = require("../../utils");
const { CommandList, SchemaStringWithDefault } = utils_1.UQLMAKER;
class IndexExtra extends connection_base_1.ConnectionBase {
/**
* 查看索引列表
*/
showAllIndex(commonReq) {
return __awaiter(this, void 0, void 0, function* () {
let command = CommandList.showIndex;
let uqlMaker = new utils_1.UQLMAKER(command, commonReq);
let res = yield this.uqlSingle(uqlMaker);
let data = {};
res.uqlReply.datas.forEach((v) => {
if (!v) {
return;
}
let t = v.asTable();
data[t.name] = t.toKV();
});
return Object.assign(Object.assign({}, res.responseWithoutData), { data: data });
});
}
/**
* 查看点跟边的索引列表
*/
showIndex(requestConfig) {
return __awaiter(this, void 0, void 0, function* () {
return this.showAllIndex(requestConfig);
});
}
/**
* 查看点或者边的索引列表
*/
showNodeOrEdgeIndex(dbType, commonReq) {
return __awaiter(this, void 0, void 0, function* () {
let command = dbType === types_1.ULTIPA.DBType.DBNODE
? CommandList.showNodeIndex
: CommandList.showEdgeIndex;
let uqlMaker = new utils_1.UQLMAKER(command, commonReq);
let res = connection_base_1.ConnectionBase.UqlListSimple(this, uqlMaker);
return res;
});
}
/**
* 查看点的索引列表
*/
showNodeIndex(requestConfig) {
return __awaiter(this, void 0, void 0, function* () {
return this.showNodeOrEdgeIndex(types_1.ULTIPA.DBType.DBNODE, requestConfig);
});
}
/**
* 查看边的索引列表
*/
showEdgeIndex(requestConfig) {
return __awaiter(this, void 0, void 0, function* () {
return this.showNodeOrEdgeIndex(types_1.ULTIPA.DBType.DBEDGE, requestConfig);
});
}
/**
* 删除点或者边的索引
*/
dropIndex(dbType, schemaName, propertyName, requestConfig) {
return __awaiter(this, void 0, void 0, function* () {
let req = {
dbType,
schema: schemaName,
propertyName
};
let command = req.dbType === types_1.ULTIPA.DBType.DBNODE
? CommandList.dropNodeIndex
: CommandList.dropEdgeIndex;
let uqlMaker = new utils_1.UQLMAKER(command, requestConfig, SchemaStringWithDefault(req.schema, req.propertyName));
let res = connection_base_1.ConnectionBase.UqlListSimple(this, uqlMaker);
return res;
});
}
// /**
// * 删除点的索引
// */
// async dropNodeIndex(
// req: RequestType.DropIndex,
// commonReq?: RequestType.RequestConfig
// ) {
// return this.dropIndex({ ...req, dbType: ULTIPA.DBType.DBNODE }, commonReq);
// }
// /**
// * 删除边的索引
// */
// async dropEdgeIndex(
// req: RequestType.DropIndex,
// commonReq?: RequestType.RequestConfig
// ) {
// return this.dropIndex({ ...req, dbType: ULTIPA.DBType.DBEDGE }, commonReq);
// }
/**
* 创建点或者边的索引
*/
createIndex(
// req: RequestType.CreateIndex,
dbType, schemaName, propertyName, requestConfig) {
return __awaiter(this, void 0, void 0, function* () {
let req = {
dbType,
schema: schemaName,
propertyName
};
let command = req.dbType === types_1.ULTIPA.DBType.DBNODE
? CommandList.createNodeIndex
: CommandList.createEdgeIndex;
let uqlMaker = new utils_1.UQLMAKER(command, requestConfig, SchemaStringWithDefault(req.schema, req.propertyName));
let res = connection_base_1.ConnectionBase.UqlListSimple(this, uqlMaker);
return res;
});
}
// /**
// * 创建点的索引
// */
// async createNodeIndex(
// req: RequestType.CreateIndex,
// commonReq?: RequestType.RequestConfig
// ) {
// return this.createIndex({ ...req, dbType: ULTIPA.DBType.DBNODE }, commonReq);
// }
// /**
// * 创建边的索引
// */
// async createEdgeIndex(
// req: RequestType.CreateIndex,
// commonReq?: RequestType.RequestConfig
// ) {
// return this.createIndex({ ...req, dbType: ULTIPA.DBType.DBNODE }, commonReq);
// }
/**
* 查看全文索引
*/
showFulltextBase(dbType, requestConfig) {
return __awaiter(this, void 0, void 0, function* () {
let command = CommandList.showFulltext;
if (dbType === types_1.ULTIPA.DBType.DBNODE) {
command = CommandList.showNodeFulltext;
}
else if (dbType === types_1.ULTIPA.DBType.DBEDGE) {
command = CommandList.showEdgeFulltext;
}
let uqlMaker = new utils_1.UQLMAKER(command, requestConfig);
let res = yield this.uqlSingle(uqlMaker);
let data = {};
res.uqlReply.datas.forEach((v) => {
if (!v) {
return;
}
let t = v.asTable();
data[t.name] = t.toKV();
});
return Object.assign(Object.assign({}, res.responseWithoutData), { data: data });
});
}
/**
* 查看全文索引列表
*/
showFulltext(requestConfig) {
return __awaiter(this, void 0, void 0, function* () {
return this.showFulltextBase(null, requestConfig);
});
}
/**
* 查看点全文索引列表
* @param commonReq
*/
showNodeFulltext(requestConfig) {
return __awaiter(this, void 0, void 0, function* () {
return this.showFulltextBase(types_1.ULTIPA.DBType.DBNODE, requestConfig);
});
}
/**
* 查看边全文索引列表
* @param commonReq
*/
showEdgeFulltext(requestConfig) {
return __awaiter(this, void 0, void 0, function* () {
return this.showFulltextBase(types_1.ULTIPA.DBType.DBEDGE, requestConfig);
});
}
/**
* 创建全文索引
*/
// async createFullText(
// req: RequestType.CreateFullText,
// commonReq?: RequestType.RequestConfig
// ) {
createFulltext(dbType, schemaName, propertyName, fulltextName, requestConfig) {
return __awaiter(this, void 0, void 0, function* () {
let req = {
name: fulltextName,
schema: schemaName,
dbType: dbType,
propertyName: propertyName
};
let command = req.dbType === types_1.ULTIPA.DBType.DBNODE
? CommandList.createNodeFulltext
: CommandList.createEdgeFulltext;
let uqlMaker = new utils_1.UQLMAKER(command, requestConfig, [
SchemaStringWithDefault(req.schema, req.propertyName),
req.name,
]);
return connection_base_1.ConnectionBase.UqlUpdateSimple(this, uqlMaker);
});
}
/**
* 删除全文索引
*/
dropFulltext(fulltextName, dbType, requestConfig) {
return __awaiter(this, void 0, void 0, function* () {
let req = {
name: fulltextName,
dbType: dbType
};
let command = req.dbType === types_1.ULTIPA.DBType.DBNODE
? CommandList.dropNodeFulltext
: CommandList.dropEdgeFulltext;
let uqlMaker = new utils_1.UQLMAKER(command, requestConfig, req.name);
return connection_base_1.ConnectionBase.UqlUpdateSimple(this, uqlMaker);
});
}
}
exports.IndexExtra = IndexExtra;
//# sourceMappingURL=index.extra.js.map