-
Notifications
You must be signed in to change notification settings - Fork 15
Separation of metadata from object data at save time? #79
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
Comments
Hi @aranasaurus - this is a really good question. Short answer is, I'm not sure - I'll confess to not doing this myself - I typically have sorting keys inside the object. However, we can try to figure out what is happening. My first question / thought is.... can you share the general structure of your model and its metadata model. I'm most interested in knowing if your metadata is a value type or a regular My second question / thought is... is it possible for you to organize your model so that the |
For your first question: My data is structured such that my Objects are all the information that is needed to display said objects, and their metadata contains just the properties that can be sorted on. Both Object and Metadata are value types. For the second question: It is not currently set up so that I could do that, but I think I could refactor it a little bit so that I could. In fact this line of thinking is what lead me here to ask the question, because I went looking into the YapDBExtensions code that writes the data and as far as I could tell it looks like it writes the metadata no matter what, so setting it to So that probably gives me what I need :) I'll try to do that refactor and let you know. Thanks! |
Yes. That's what it boils down to. There is perhaps some smarts that can be added here if your MetadataType conformed to Equatable... |
It does. That's probably what I'm going to do, in my write transaction, check if the metadata of the already cached version is the same as the updated object, and if so set it to |
Yeah :). And this framework could do that automatically for you I think... |
It'd be nice if the framework checked for equality on the metadata before writing it... especially if it meant that when I write an object with a |
Yeah, totally agree with you. It's a really subtle behavior that it might as well be considered a bug. Will look to address this at the same time. |
Okay, made a quick start at this on my way to work this morning. See #80. |
Awesome, looking forward to it! |
This is definitely a question, not a bug report, so read accordingly :)
I've recently been re-structuring my data a bit so that I have the fields that I sort on in the Metadata and everything else in the object data. Reading https://github.com/yapstudios/YapDatabase/wiki/Views#initialization-tips suggests that is the recommended way to avoid unnecessary recalculation of the sortings. The problem I'm running into is that because YapDatabaseExtensions writes the metadata every time it writes an object, even if that metadata hasn't changed, every time I write an object the database my sort blocks are being run, even though I haven't updated their sort-able properties.
My question is, am I missing something? Is there a way that I can accomplish this with YapDatabaseExtensions or is this an approach that it's just not designed for?
The text was updated successfully, but these errors were encountered: