Skip to content
This repository has been archived by the owner on May 20, 2021. It is now read-only.

How to map embedded data from Meteor responce? #51

Open
Avtolic opened this issue Jul 22, 2015 · 3 comments
Open

How to map embedded data from Meteor responce? #51

Avtolic opened this issue Jul 22, 2015 · 3 comments

Comments

@Avtolic
Copy link

Avtolic commented Jul 22, 2015

Hello

Could someone please tell me how should be CoreData model designed to work correctly with the following Meteor responses:

{
    collection = users;
    fields =     {
        profile =         {
            accountType = student;
            birthday = "<null>";
            firstName = YuryTestStudent3;
            fullName = YuryTestStudent3;
            lastName = "";
            level = 1;
            parentId = R72enQ6CMus7w95gn;
            teacherId = ggGggDkQvQYFqzojT;
        };
        username = "@child_R72enQ6CMus7w95gn_06327e8c-1def-4e0c-ba1e-019666ff969f";
    };
    id = MMn5PeQiTyoPgM7KF;
    msg = added;
}

As you can see some data is not directly inside fields but is in profile. How this response should be mapped? Should I create a separate profile table? Or should mapping logic be changed? meteor-ios lib is great but quite complex so if anyone could help me or show the right direction it will be great.

Thank you

@martijnwalraven
Copy link
Owner

The best way to support embedded value objects like this is through a 'transformable' mapping to a dictionary in Core Data. The Todos example has a mapping for 'profile' set up as part of User.

@LinkXXI
Copy link

LinkXXI commented Aug 24, 2015

Is it possible to add support for mapping embedded data?

I have a situation currently where I'd like to use a predicate to filter on some embedded data (it's probably bad design but I can't change it at this point).

Being able to map an embedded property using fieldName pofile.accountType in the User Info section of the data model.

@calioasis
Copy link

@LinkXXI
You can still filter on embedded data. Just create a derived variable for whatever you want to access. Since this library doesn't use SQLite as a backing store, you can run a query against anything

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

4 participants