Skip to content
This repository has been archived by the owner on Jul 31, 2022. It is now read-only.

Array operations #3

Open
gormster opened this issue Dec 14, 2016 · 1 comment
Open

Array operations #3

gormster opened this issue Dec 14, 2016 · 1 comment

Comments

@gormster
Copy link

Pretty quickly realised that setProperty doesn't work to add new values to an array (you get, predictably, an "Index out of range" fatal error). So, we need append(_:forKey:) to add new values to the end of an array, and remove(at:forKey:) to remove & renumber the remaining elements. This should be executed using $push and $pop ideally, but if keys have both been added and removed then it may be necessary to use $set (I don't think there's a way to reorder an array in a single DB call).

I think possibly it might be better for the mutatedFields document to be the actual update document and just keep track of sets, unsets, pushes and pops as the Instance itself is mutated. Thoughts?

@Joannis
Copy link
Member

Joannis commented Dec 14, 2016

Ah.. good one! I've honestly never mutated an array with Mainecoon. I was planning on making it the update document, but since I'm a bit loaded with work I didn't have the time to do this yet.

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

No branches or pull requests

2 participants