Loopback: DELETE on a related item doesn't return anything

Created on 28 Jun 2016  路  10Comments  路  Source: strongloop/loopback

when i do DELETE /api/modela/id/modelb/fk , the response is status 204 with empty body content, and should be { count : 1 } like normal DELETE operation in anothers endpoints

this happend to me on mongodb 3.2 , using lastest connector, lastest loopback 2.29.0

bug stale

Most helpful comment

@Amir-61 @jannyHou i just tested with MongoDB 2.4.9 on my server, and same problem, i also made this test using memory db and same issue

All 10 comments

@hgouveia I am trying to reproduce your problem, could you fork this sandbox and replace it with your code? Thanks.

@jannyHou , this is the fork https://github.com/hgouveia/loopback-sandbox , i already added some migration in the code to ease the process,

to reproduce, please run the server, go to the explorer, and try to delete a comment from a post

_Step 1_
screenshot 57

_Step 2_
screenshot 58

_Step 3_
screenshot 59

@hgouveia Thanks i reproduced it.

I am not sure does destroyById also return the count, from our doc it only callback the error msg. But from the code it should include count since it eventually called destroyAll, which certainly returns count
@Amir-61 could you help confirm does destroyById contain count? Thanks.

But the bug still exist since even DELETE/Posts/{id}/comments doesn't return the count
screen shot 2016-07-15 at 11 40 08 am

@Amir-61 could you help confirm does destroyById contain count? Thanks.

It should return info object indicating the number of affected/deleted items even in NoSQL connectors like loopback-connector-mongodb; please see here, info object is returned by destroyId from loopback-connetcor-mongodb. If it does not return count, it seems a bug to me; also I suspect this can be a compatibility issue between different versions of mongodb; could you or @hgouveia try other mongodb versions (e.g. mongodb 2.6 and 2.4) to see if you see the same bug with these version?

@Amir-61 @jannyHou i just tested with MongoDB 2.4.9 on my server, and same problem, i also made this test using memory db and same issue

@jannyHou @Amir-61 Could we reopen this?

I am running into this same issue; I try to remove a relation to an item by id but a status code of 204 is returned and the relation is not removed. (using the cloudant connector though)

@jackrvaughan I have moved away from LB development for a while; however @jannyHou is still on LoopBack; @jannyHou could you help on this issue please? Thanks!

UPDATE: This was an error on my side. My loopback-connector-cloudant was out of date; after updating, everything works as expected. Sorry for requesting to reopen the issue.


@jannyHou After some investigation, I think this could be an issue on my side. Anytime I try to remove an item from an array within a model instance (say through PATCH /model/id for example), it returns the expected instance value with the item from the array removed; but when I request it again via GET model/id it returns the array with the item I just deleted included.

For example, if my instance starts as:

{
  "name": "Jackson",
  "favorites": [
    "apples",
    "cherries"
  ],
  "id": 1
}

And I run PATCH user/1 with this body:

{
  "name": "Jackson",
  "favorites": [
    "apples"
  ]
}

It returns the expected value (without cherries):

{
  "name": "Jackson",
  "favorites": [
    "apples"
  ],
  "id": 1
}

But if I run GET user/1 again, I get this back:
{ "name": "Jackson", "favorites": [ "apples", "cherries" ], "id": 1 }

But I can't seem to reproduce this with the sandbox 馃槙 Would you have any ideas on what might be causing this?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Overdrivr picture Overdrivr  路  4Comments

germanamz picture germanamz  路  3Comments

rkmax picture rkmax  路  3Comments

bajtos picture bajtos  路  4Comments

ImanMh picture ImanMh  路  4Comments