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'm trying to use EntityManager to write an update statement to remove a nested attribute, kind of like the following
import{Attribute,Entity,Table}from'@typedorm/common';import{createConnection,getEntityManager}from'@typedorm/core';importAWSfrom'aws-sdk';importDynamoDB=AWS.DynamoDB;exportclassMyEntityAttribute{publicreadonlyname: string|undefined;publicreadonlyvalue: string|undefined;}
@Entity<MyEntity>({name: 'MyEntity',primaryKey: {partitionKey: 'MyEntity#{{id}}',},})exportclassMyEntity{
@Attribute()publicid: string|undefined;
@Attribute()publicattribute: MyEntityAttribute|undefined;}exportasyncfunctionremoveName(id: string): Promise<void>{consttable=newTable({name: 'MyTable',partitionKey: 'pk'});createConnection({table: table,entities: [MyEntity],documentClient: newDynamoDB.DocumentClient()});constentityManager=getEntityManager();awaitentityManager.update(MyEntity,{ id },{//// This doesn't work, the TSC error is the following///* Type '{ name: { REMOVE: true; }; }' is not assignable to type '((SetValueType<MyEntity, "attribute"> | (Omit<{ ADD?: InvalidType<["number | any[]", "Update action 'ADD' can not be used for attribute", "attribute"]> | undefined; }, "ADD"> & Required<...> & Partial<...>) | (Omit<...> & ... 1 more ... & Partial<...>) | (Omit<...> & ... 1 more ... & Partial<...>)) & (SetValueType<....'. Type '{ name: { REMOVE: true; }; }' is not assignable to type 'Omit<{ DELETE?: InvalidType<[any[], "Update action 'DELETE' can not be used for attribute", "attribute"]> | undefined; }, "DELETE"> & Required<Pick<{ DELETE?: InvalidType<...> | undefined; }, "DELETE">> & Partial<...> & { ...; }'. Property 'DELETE' is missing in type '{ name: { REMOVE: true; }; }' but required in type 'Required<Pick<{ DELETE?: InvalidType<[any[], "Update action 'DELETE' can not be used for attribute", "attribute"]> | undefined; }, "DELETE">>'.ts(2322) update-body-type.d.ts(56, 5): 'DELETE' is declared here. example.ts(23, 5): The expected type comes from property 'attribute' which is declared here on type 'UpdateBody<MyEntity, { attribute: { name: { REMOVE: boolean; }; }; }>' */attribute: {name: {REMOVE: true},},},);}
I don't think this is supported by TypeDORM at this time, but I hope I've missed something.
The text was updated successfully, but these errors were encountered:
I'd still love to hear information from the community, it's likely I'm missing something.
But, to update from what I've found.
TypeDORM can't work with nested attributes through entity manager.
I ended up refactoring entities here, to avoid the necessity of working with nested attributes. It's not a great solution in general, I think, but it worked.
I'm trying to use
EntityManager
to write an update statement to remove a nested attribute, kind of like the followingI don't think this is supported by TypeDORM at this time, but I hope I've missed something.
The text was updated successfully, but these errors were encountered: