Skip to content

Commit

Permalink
Use modelInstanceCreator for fromJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
ericclemmons committed Apr 17, 2020
1 parent 4733b5c commit 644a5f1
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions packages/datastore/src/datastore/datastore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,7 @@ const createModelClass = <T extends PersistentModel>(
return json.map(init => this.fromJSON(init));
}

const { id, ...init } = json;

// ! This is a double-init because `id` can't be provided via `new`.
return produce(
new clazz(init as ModelInit<T>),
(draft: Draft<T & ModelInstanceMetadata>) => {
initializeInstance(init, modelDefinition, draft);

draft.id = id;
}
);
return modelInstanceCreator(clazz, json);
}
});

Expand Down

0 comments on commit 644a5f1

Please sign in to comment.