【问题标题】:Laravel NeoEloquent ignores "CONSTRAINT" on ::create commandLaravel NeoEloquent 忽略 ::create 命令上的“CONSTRAINT”
【发布时间】:2017-02-10 09:49:44
【问题描述】:

所以我刚开始编写我的 API,就遇到了这个错误:

在创建具有唯一CONSTRAINT 两次的用户时,返回异常,但仍在创建节点!

CONSTRAINT 位于“User:access_token”属性上, 我正在使用以下代码:

try {
    $userAttributes = [
        "email" => $request->email,
        "access_token"  =>  'aaaa',
        "facebook_id"   =>  'bbbb'
    ];
    $user = new User($userAttributes);
    $user->save();
}catch (Exception $e){}

有什么帮助吗?

【问题讨论】:

  • 您能否在您的 Neo4j 浏览器中运行 :schema 以确保正确创建了约束?似乎问题超出了 OGM 范围。
  • @Mulkave 下面是模式命令的输出: Indexes ON :User(email) ONLINE(用于唯一性约束) ON :User(access_token) ONLINE(用于唯一性约束) Constraints ON (user:User )断言 user.access_token 是唯一的(用户:用户)断言 user.email 是唯一的

标签: php neo4j laravel-5.2 neoeloquent


【解决方案1】:

此问题是由于 underlying driver 使用 REST API 而不是执行 Cypher 查询造成的。作为一种解决方法(在此答案时),有一个 NeoEloquent 分支1.5-dev 使用不同的驱动程序,它将用于针对数据库运行 Cypher。该分支仍在开发中,但目前完全向后兼容。

要安装它,请将版本dev-1.5-dev 添加到您的composer.json 文件并运行composer update vinelab/neoeloquent

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-04
    • 2012-04-04
    • 1970-01-01
    • 2023-03-13
    相关资源
    最近更新 更多