#Cant delete items from data manager

7 messages · Page 1 of 1 (latest)

coral mortar
#

I get this error:
Validation error of type FieldUndefined: Field 'id' in type 'Trainer' is undefined @ 'deleteTrainer/id'

The items disappear - then when you re-load the reappear.

I can manually remove them from dynamo as a work around.

slim finch
#

Hi @coral mortar , can you share the schema?

coral mortar
#

@slim finch I've got a feeling its because I made a change. Set email to be the identifier. But yea one sec - I'll get the schema.

#
const schema = a.schema({
  Trainer: a
    .model({
      name: a.string(),
      email: a.string().required(),
      businessId: a.id(),
      business: a.belongsTo('Business', 'businessId')
    })
    .authorization((allow) => [allow.owner()])
    .identifier(['email']),
  Business: a
    .model({
      trainers: a.hasMany('Trainer', 'businessId'),
      businessName: a.string(),
      logo: a.string(),
      colours: a.customType({
        colourOne: a.string(),
        colourTwo: a.string()
      })
    })
    .authorization((allow) => [allow.owner()])
});
slim finch
#

that could be the case, setting email as the identifier means that it acts as the primary Key and id is not added to the schema by Amplify. But, the Data Manager should be able to use the correct field as the primary key to delete items with after deploying the schema

#

have you pushed the new schema to your branch connected to the hosted Amplify app?

#

or do the changes only exist in a sandbox so far?