Closed dcromster closed 3 years ago
Do you have a record already in the table with id
of 1? NB id
will be the primary key for the table, not ServiceID
.
If that's not the cause, please try removing the line configDataTable.isHierarchy()
and parentId: 1
from the query and see if the query still fails. If so, then the error has nothing to do with sequelize-hierarchy and is some other constraint failure.
NB hierarchyLevel
does not need to be specified in your query. sequelize-hierarchy will fill that field automatically for you.
Let me know if that helps.
Thanks for the quick response!
Yes, I have one record with id = 1. This record was inserted normally. Yes, id the primary key.
Found an error in the database: auto-increment was not set on id.
But now I got new error when I try to insert second row:
await configDataTable.create({ serviceID: 1, keyName: 'Root2', keyValue: '', KeyType: 2, // hierarchyLevel: 1, // aclCreator: 'n', // aclGroup: 'n', // aclOthers:'n', parentId: 1 });
UnhandledPromiseRejectionWarning: SequelizeDatabaseError: Table 'configDataancestors' doesn't exists.
This part of documentation I didn't understand well too. How create this table?
Please see here in the docs for solution.
Hello!
I didn't find an example of correct data insertion in the documentation, and that's why I'm suffering. On insertion, I get "(node: 31110) UnhandledPromiseRejectionWarning: SequelizeUniqueConstraintError: Validation error"
My insertion:
await configDataTable.create({ serviceID: 1, keyName: 'Root', keyValue: '', KeyType: 2, // hierarchyLevel: 1, parentId: 1 });
does not work without parentId either.
It inserts once, and then no more rows can be inserted into the table.
Table: