小编Ric*_*rdW的帖子

Neo4j Cypher:如何迭代ExecutionResult结果

在这段代码中,我如何迭代ExecutionResult结果中的所有节点?

CypherParser parser = new CypherParser();
ExecutionEngine engine = new ExecutionEngine( graphDb );
Query query = parser.parse( "START n=node(2) MATCH (n)<-[:IS_A]-(x) RETURN x" );
ExecutionResult result = engine.execute( query );
// iterate over nodes in result and print all properties
Run Code Online (Sandbox Code Playgroud)

neo4j cypher

8
推荐指数
1
解决办法
5868
查看次数

Chrome扩展程序:如何禁用页面可见性API

我正在编写一个Chrome扩展程序,需要阻止网页触发文档可见性更改事件.至少我需要能够覆盖document.visibilityState(即使它是一个只读属性).如果不可能,因为此扩展程序仅用于我的目的而不会在Chrome扩展程序商店中,我是否可以通过配置Chrome浏览器来实现我的目标?我只需要在Chrome"开发者模式"启用时使用此扩展程序,而不是其他时间.

我希望有人能想出一种创造性的方法来实现这一目标.谢谢.

请注意!4年前的答案中有一个解决方案,在较新版本的Chrome中不再生效: 欺骗或禁用Page Visibility API

自己测试一下:

// This codes worked 4 years ago but not anymore
var c='(function(){var a=Node.prototype.addEventListener;Node.prototype.addEventListener=function(e){if(e=="visibilitychange"||e=="webkitvisibilitychange"){}else a.apply(this,arguments)}})()'
, E=document.documentElement;
E.setAttribute('onreset', c);
E.dispatchEvent(new CustomEvent('reset'));
E.removeAttribute('onreset');

// THIS WILL STILL LOG THE STATES EVEN WITH THE ABOVE CODE RUNNING
document.addEventListener("visibilitychange", function() {
    console.log( document.visibilityState );
});
Run Code Online (Sandbox Code Playgroud)

如果在Chrome中无法实现,是否有Firefox/Safari/Opera浏览器代码可以实现这一目标?

javascript jquery html5 google-chrome google-chrome-extension

6
推荐指数
1
解决办法
1456
查看次数

neo4j动态关系类型,而不是枚举

我如何使用字符串"KNOWS"并将其用作关系类型而不是使用枚举RelTypes.KNOWS ...我需要动态添加关系而不是仅使用2个枚举RelTypes.KNOWS和RelTypes.IS_FRIENDS_WITH

// START SNIPPET: createReltype
private static enum RelTypes implements RelationshipType
{
    KNOWS,
    IS_FRIENDS_WITH
}
// END SNIPPET: createReltype

public static void main( final String[] args )
{
    // START SNIPPET: startDb
    GraphDatabaseService graphDb = new EmbeddedGraphDatabase( DB_PATH );
    registerShutdownHook( graphDb );
    // END SNIPPET: startDb

    // START SNIPPET: operationsInATransaction
    Transaction tx = graphDb.beginTx();
    try
    {
        Node john = graphDb.createNode();
        john.setProperty("name", "John" );
        Node george = graphDb.createNode();
        george.setProperty("name", "George" );

        firstNode.createRelationshipTo( secondNode, RelTypes.KNOWS );

        tx.success();
    }
    finally
    {
        tx.finish(); …
Run Code Online (Sandbox Code Playgroud)

java enums neo4j

5
推荐指数
1
解决办法
2621
查看次数