# I can not delete Users using Custom Database

**URL:** <https://community.auth0.com/t/i-can-not-delete-users-using-custom-database/7027>\
**Category:** Get Help\
**Tags:** custom-database, delete-user\
**Created:** [June 12, 2017, 11:04pm UTC](https://community.auth0.com/t/i-can-not-delete-users-using-custom-database/7027 "2017-06-12T23:04:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kusanagi2k2](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@kusanagi2k2](https://community.auth0.com/u/kusanagi2k2)\
**Post date:** [June 12, 2017, 11:04pm UTC](https://community.auth0.com/t/i-can-not-delete-users-using-custom-database/7027/1 "2017-06-12T23:04:09Z")

</div>

Hello!

I am trying to delete a user using the the templates of custom database → delete section.  
When I do the test always the result is "The user was successfully deleted, but I can see in my database the user is still there… when I delete the user from the dashboard the user is deleted in the user collection in the dashboard but not in my database.  
Maybe I am missing something.

I appreciate your help.

---

<div class="post-metadata">

**Author:** ![prashantT](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/prashantt/32/6002_2.png) [@prashantT](https://community.auth0.com/u/prashantT)\
**Post date:** [June 13, 2017, 5:52am UTC](https://community.auth0.com/t/i-can-not-delete-users-using-custom-database/7027/2 "2017-06-13T05:52:32Z")

</div>

This indicates an issue with your Delete script. You will need to make sure that your script actually deletes the user from your custom database. An example for Mongo:

```
...
users.remove({ _id: id }, function (err) {
  if (err) return callback(err);
  callback(null);
});

```

To debug, you can use `console.log()` statements in your script, and the [Realtime Webtask Logs extension](https://auth0.com/docs/extensions/realtime-webtask-logs) to review the logs.

---

<div class="post-metadata">

**Author:** ![patryk](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@patryk](https://community.auth0.com/u/patryk)\
**Post date:** [September 5, 2017, 5:36pm UTC](https://community.auth0.com/t/i-can-not-delete-users-using-custom-database/7027/3 "2017-09-05T17:36:48Z")

</div>

There’s one problem though - usually \_id of doc in MongoDB is stored as ObjectId. Hence there’s a difference between:  
{\_id: ‘123123123123’}  
and  
{\_id: ObjectId(‘123123123123’)}  
The first one won’t do nothing but the second one will actually delete that user.

Is there a way to access ObjectId constructor inside of custom database scripts?

Thank you for your answer!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:54am UTC](https://community.auth0.com/t/i-can-not-delete-users-using-custom-database/7027/4 "2018-03-02T05:54:35Z")

</div>


