【发布时间】:2020-06-08 15:16:37
【问题描述】:
我正在将 OrientDb 与 JavaScript 一起使用,并且我尝试过使用startingWith、containing、endingWith、notContaining、notEndingWith、notStartingWith 谓词失败。也许是我这边的错误实现,但我还没有找到有关如何使用的文档。
我一直在寻找一种使用 lambdas 过滤以获得 sql like 行为的方法,但没有成功。我尝试使用 described in this answer 方法,但它不适用于 JavaScript。使用谓词时,答案是错误的。
我也试过了: What is the equivalent of the gremlin queries in gremlin javascript?
我当前的 JavaScript 代码:
import * as gremlin from 'gremlin';
const traversal = gremlin.process.AnonymousTraversalSource.traversal;
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
const TextPredicated = gremlin.process.TextP;
const authenticator = new gremlin.driver.auth.PlainTextSaslAuthenticator('usr', 'pwd');
const remote = new DriverRemoteConnection(
'ws://localhost:8182/gremlin', {
authenticator,
traversalSource: 'g'
});
remote.addListener('socketError', (error) => { console.log(`socketError: ${error}`); });
(async () => {
try {
remote.open();
const g = await traversal().withRemote(remote);
const results = await g.V()
.where('username', TextPredicated.containing('john'))
.toList();
console.log(results);
remote.close();
} catch (error) {
console.log(error);
} finally {
remote.close();
}
})();
【问题讨论】:
标签: javascript orientdb gremlin predicate