-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transaction ExecPostHooks missing entityData #115
Comments
Hello, |
Transaction Example
|
Hi, A few comments on your code example: const eventSchema = new Schema({
organizerId: { type: String, required: true },
created: { type: Number, write: false },
modified: { type: Number, write: false },
version: { type: String, default: process.env.AppVersion, write: false },
creatorId: { type: String, required: true, write: false },
// additional props
...
});
// You don't need to set { explicitOnly: true, keyType: 'id' }, it is the default
async function setCreatorPermissions() {
console.log('here i do some stuff with permissions...');
return new Promise.resolve(); // remove the "new"
}
...
const transaction = gstore.transaction();
await transaction.run();
try {
const event = await Event.get(eventId); // why this line?
const itemData = Event.sanitize(cartData);
const item = new Event(
itemData
);
const event = await item.save(transaction); // Set the "event" here not on the "get"
await transaction.commit();
await transaction.execPostHooks();
if (event[gstore.ERR_HOOKS]) {
return {
success: false,
...event[gstore.ERR_HOOKS][0],
};
}
....
} |
Okay will try in a day or so and report back! Thank you for taking the time to read and comment over the code! |
Great, happy to help. Let me know how it goes! |
It worked! Thank you so much. |
Great, thanks for the feedback! 👍 |
When doing a transaction and after calling execPostHooks on the transaction my post save functions do not have 'this' set to the current entity. Which means I am unable to work with the entity in my post save hooks for example when I am using transactions.
The text was updated successfully, but these errors were encountered: