Delete belongsTo relationship

Expected behavior

When viewing list of records in a belongs to relationship, selecting a record and then delete leads to a refresh, but no delete end point is ever called.

Actual behavior

Does not call any endpoint

Failure Logs

Please include any relevant log snippets, if necessary.

Context

Please provide any relevant information about your setup.

  • Package Version:
  • Express Version:
  • Sequelize Version:
  • Database Dialect:
  • Database Version:
  • Project Name:

Hi @Liam_Cheung !

Can you fill out the context part of your post ?
Can you share the models linked to the collections that have the belongsTo relationship ?

@Liam_Cheung Looking at your screenshot it looks like a hasMany relationship.

Here Audit test hasMany Documents

When deleting a document from an Audit test, no route/end point is ever called.

Is that right?

Hi,

Yes that is correct.

Liam

Hello @Liam_Cheung :wave:

I couldn’t reproduce this with a hasMany relationship. Do you have any errors in your console ?

Steve.

Nothing in the console that I can see…

Note that this only happens when accessing the record through a relationship, it does work when accessing the collection directly.

Liam

Hey @Liam_Cheung,

Could you send a video reproducing this issue with your network tabs open please :pray:. You can use Loom for example.

Hi, I uploaded a quicktime to my google drive. I am hoping you can ask for permission to view and I can grant it.
https://drive.google.com/file/d/1HqySxBlRan23nJMXNFvckYfg6m_it09H/view?usp=sharing

Hi @Liam_Cheung,
I am sorry but the video quality is so low that I cannot read the error messages.
Would you mind doing this record with something like Loom?
Thanks!

1 Like

I just shared with you the high quality version of the file.

Hi @Liam_Cheung,

Are your “Documents” linked to “Audit Test” via a smart relationship ? I’ll test in that specific case but I think this might be related to the original issue

In collection(‘users’, …fields: […
{
field: ‘documents’,
type: [‘String’],
reference: ‘document._id’,
}
], …)

Great. And I guess your Documents is similar to the one from our Smart collections example ?

I’m currently giving this setup a try, just to make sure I’m able to reproduce

Actaully I see what you mean now. Both users and documents are regular mongo collections.

Hi @Liam_Cheung,

Could you tell me how your Documents are related to the Users collection? Is that a subcollection (ie. documents are stored directly on users and displayed as a relationship)? Or a reference (ie. any document carry a reference to a user)?

Thanks in advance, that might be of some help to reproduce your issue.

As a reference. The document has a field user_id so the relationship lists all documents with that user id.

Hey @Liam_Cheung I’ve added a ticket on our end to tackle this issue asap. I’ll let you know once we have something on our end.

1 Like

@Liam_Cheung We’ve released a fix! We now trigger HTTP DELETE for hasMany smart relationship. Let us know if that helps!

2 Likes

Hi @louis

Thanks for this. I notice that the url comes in as:
Request URL:https://forest-map.qa.eu.mylo.ai/forest/users/5f18847ea674170007ede6ef/relationships/documents?delete=true

Request Method: DELETE

Does the parameter delete=true at the end mean anything?

Also the payload seems a little differnt than normal, when we ask to delete multiple records in a regular collection we get this payload:
image

Which is parsable with RecordsGetter.getIdsFromRequest

With this one will there be a parser to get the ids?
image

Liam