Skip to content
This repository has been archived by the owner on Jun 5, 2019. It is now read-only.

Entries get updated when field slugs change #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rubenvereecken
Copy link
Contributor

Uses a virtual old.slug to keep track of the old Field slug. If it changes a post save will make sure all related Fields get renamed as well. Should be changed along with the rest of the changes for #168 (assembly).

Uses a virtual `old.slug` to keep track of the old Field slug. If it changes a `post save` will make sure all related Fields get renamed as well. Should be changed along with the rest of the changes for #168 (assembly).
@davidkaneda
Copy link
Contributor

Hey @rubenvereecken, looks great, could you add a test for it?

@rubenvereecken
Copy link
Contributor Author

I only ranted 5 times. There's a minor edge case I haven't found after hours of search. It only happens when Mongoose does something quirky so virtuals get lost along the way. We'll have to be careful with updates and such since those circumvent middleware - I've always tried avoiding them.

Anyway, works like a charm for our use cases.

@davidkaneda
Copy link
Contributor

Yeah, that Model.update thing (going without middleware) is kinda lame. I know where mongoose is coming from, passing it through directly to the Mongo client, but still: could be an option or something... Will take a look at this over the weekend, looking forward to it :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants