neode
neode copied to clipboard
TransactionError when installing schema
I receive an error every time I start up my server with this error
TransactionError: ERROR_TRANSACTION_FAILED
at /home/taylor/duw/api/node_modules/neode/build/index.js:434:23
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
errors: [
{
query: 'CREATE CONSTRAINT ON (model:Story) ASSERT model.id IS UNIQUE',
params: {},
error: [Neo4jError]
},
{
query: 'CREATE CONSTRAINT ON (model:User) ASSERT model.id IS UNIQUE',
params: {},
error: [Neo4jError]
},
{
query: 'CREATE CONSTRAINT ON (model:User) ASSERT model.email IS UNIQUE',
params: {},
error: [Neo4jError]
}
]
}
This issue doesn't seem to affect any other operation. just wondering what may have caused this issue.
What is the message on those error messages?
I have this in my server file.
neode.schema.install() .then(() => console.log('Schema installed')) .catch((err) => console.log(err));
The Error message: TransactionError: ERROR_TRANSACTION_FAILED
Try
.catch((err) => console.log(err.errors.map(error => error.message))
That should give you some more info on what has actually gone wrong
After adding the error log I get this now
[ undefined, undefined, undefined ]
That's strange... have you got a repo that I can take a look at?
Getting the same error while installing the schemas. error:
[
{
query: 'CREATE CONSTRAINT ON (model:Box) ASSERT model.uuid IS UNIQUE',
params: {},
error: Neo4jError: An equivalent constraint already exists, 'Constraint( UNIQUE, :Box(uuid) )'.
:
at captureStacktrace (/Users/jay/workspace/extra/linkbox-api/node_modules/neo4j-driver/lib/result.js:263:15)
at new Result (/Users/jay/workspace/extra/linkbox-api/node_modules/neo4j-driver/lib/result.js:68:19)
at newCompletedResult (/Users/jay/workspace/extra/linkbox-api/node_modules/neo4j-driver/lib/transaction.js:449:10)
at Object.run (/Users/jay/workspace/extra/linkbox-api/node_modules/neo4j-driver/lib/transaction.js:287:14)
at Transaction.run (/Users/jay/workspace/extra/linkbox-api/node_modules/neo4j-driver/lib/transaction.js:123:32)
at /Users/jay/workspace/extra/linkbox-api/node_modules/neode/build/index.js:422:21
at Array.map (<anonymous>)
at Neode.batch (/Users/jay/workspace/extra/linkbox-api/node_modules/neode/build/index.js:417:34)
at InstallSchema (/Users/jay/workspace/extra/linkbox-api/node_modules/neode/build/Schema.js:64:16)
at Schema.install (/Users/jay/workspace/extra/linkbox-api/node_modules/neode/build/Schema.js:102:14) {
code: 'Neo.ClientError.Schema.EquivalentSchemaRuleAlreadyExists',
name: 'Neo4jError'
}
}
]
I am using nestjs and using provider to connect and install the schemas.
In my nestjs provider:
export const neo4jProvider = {
provide: 'Neo4jProvider',
useFactory: async () => {
const instance = new Neode(
process.env.NEO4J_URL,
process.env.NEO4J_USER,
process.env.NEO4J_PASSWORD,
);
try {
console.log('Schema initialization');
instance.model(Model.Box, BoxSchema);
await instance.schema.install();
console.log('Schema installed');
return instance;
} catch (error) {
console.log(error.errors);
}
},
};
This isn't necessarily a problem as long as you catch the error. It's just saying that the constraint already exists. In the next release I'll handle these errors in a better way.
I love that you're using Nest by the way, have you got a link to the repo so I can see how you're using it?
I have the same error, the schemas are installed when I start application. Any prevision for next release to fix it?