How to handle partially embedded records?
I've been having some trouble using Ember Data with my MongoDB back-end. Let's say I have a User model, which contains a Media (the user picture). Sometimes user.picture
is sent embed, sometimes the back-end only sends the Media ID.
How do I handle that with Ember Data? I haven't seen anything like this in the EmbeddedRecordsMixin, even if I think it's kinda easy to do (if it's an object, don't fetch it, if it's a string, fetch the corresponding object).
With the EmbeddedRecordsMixin you can configure each per type adapter (or your app adapter) for the serialization needs to serialize records
or ids
But I do not think there is a way to sometimes use an id
or sometimes use an embedded record
in the payload. You would need to write your own custom adapter to handle that use case.
上一篇: Java套接字:我可以用一个线程写一个TCP服务器吗?
下一篇: 如何处理部分嵌入的记录?