You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to serialize a Set (using custom propSchema like in #157), but would like the result to use a reference inside the custom PropSchema to point to objects in the Set.
This doesn't work though:
import{identifier,reference,createModelSchema}from'serializr'// transmitters is a Set// Transmitter is the class of each Set itemcreateModelSchema(Receiver,{id: identifier(),// Want this to be a list of refstransmitters: custom((model)=>{constarray=Array.from(model)returnarray.map(()=>{returnreference(Transmitter)})},deserializer)})
Is there a way to do this?
The text was updated successfully, but these errors were encountered:
You can't use reference in that manner as it returns a PropSchema, not an actual object.
You should be able to achieve what you are trying with the following. The docs could be improved though.
createModelSchema(Receiver,{id: identifier(),// Want this to be a list of refstransmitters: custom((model)=>{constarray=Array.from(model)returnarray.map(x=>x.id/* or whatever is the id prop for transmitters */)},(identifierValue,done,context)=>context.rootContext.await(Transmitter,identifierValue,done);)})
I am trying to serialize a Set (using custom propSchema like in #157), but would like the result to use a
reference
inside thecustom
PropSchema to point to objects in the Set.This doesn't work though:
Is there a way to do this?
The text was updated successfully, but these errors were encountered: