I am trying to understand how to organize my node api code using neo4j as a db. I am using neo4j-javascript-driver.
I am trying to create constraints on some user fields. But I am not sure where to put the code. Because these create constraint statements should run only once. I thought of manually running statements on neo4j UI where you can run statements, but what if I go production, where I might not want to have to run statements again.
My code :
session
.run("CREATE CONSTRAINT ON (user:USER) ASSERT user.email IS UNIQUE")
.then((result) => {
console.log("neo4j constraints successful");
neoSession.close();
})
.catch((error) => {
console.log("constraint.js error : ",error);
});