# Save User Profile Data using Rule in a local Data base

**URL:** <https://community.auth0.com/t/save-user-profile-data-using-rule-in-a-local-data-base/7175>\
**Category:** Get Help\
**Tags:** rules, profile, login, user-creation\
**Created:** [June 21, 2017, 10:24am UTC](https://community.auth0.com/t/save-user-profile-data-using-rule-in-a-local-data-base/7175 "2017-06-21T10:24:18Z")\
**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 21, 2017, 10:24am UTC](https://community.auth0.com/t/save-user-profile-data-using-rule-in-a-local-data-base/7175/1 "2017-06-21T10:24:18Z")

</div>

Hello!  
I am using Auth0 to login with my custom DB and I am using FB as provider.  
I want to save all the coming data of the user after he logged . Now I can do that using Rules  
I save the data of the user in another database because I do not want to affect the data of Auth0 but the json is very weird with strange fields $t , $v for example:

```
 "age_range": {
      "$t": 3,
      "$v": {
        "min": {
          "$t": 16,
          "$v": 21
        }
      }

```

As you can see it is very difficult to read and get the results I know depending of the provider the profile could be different.  
I could see using Auth0 API I can get a normalized User Profile and all the data from another providers in a friendly way to read.  
I would like to know if there is a easier way to save this data with the same structure of User Profile(easy way to read) in my database maybe getting the profile user data from the Auth0 API using a rule.  
Thank you for your help!

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [June 21, 2017, 5:21pm UTC](https://community.auth0.com/t/save-user-profile-data-using-rule-in-a-local-data-base/7175/2 "2017-06-21T17:21:20Z")

</div>

The age range coming from Facebook would be in a format like `age_range: { min: 21 }` so the format you mention seems to be a translation from the original format to a different one where each property is expanded into `$t` and `$v` where `$v` likely represents the original value and `$t` possibly some metadata information.

This indicates that root cause of the issue is likely how you to store or read data from the database. doing a Google search suggests that you may get a format similar to that one if you’re using a Mongo library when talking to DocumentDB.

If you’re indeed talking to DocumentDB I would recommend you to try the specific SDK instead of trying to leverage the Mongo API compatibility. You should be able to use the DocumentDB Node.js SDK from a rule, in particular, with something like this:

```
var documentdb = require('documentdb@1.5.1');

```

It’s not the latest version, but it may resolve your situation.

---

<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 22, 2017, 12:11am UTC](https://community.auth0.com/t/save-user-profile-data-using-rule-in-a-local-data-base/7175/3 "2017-06-22T00:11:28Z")

</div>

Thank you for your answer!  
Sorry but I am a beginner using auth0 I need to learn many things.  
I did some research about this problem and now I can see the json that I want to save as document is invalid.

here is the json that I want to save I got this directly from the user in the rule(I mean I am saving the object user from the rule)

```
{ _id: '507fe250ba35a09cf6d39d027f75b10a',
  email: 'test1@outlook.com',
  email_verified: false,
  clientID: 'gi1FcFBUSEX7c6srmZbgcR3m_IViva2F',
  updated_at: '2017-06-21T16:58:51.589Z',
  name: 'test1@outlook.com',
  picture: 'xxx',
  user_id: 'xxx',
  nickname: 'test1',
  user_metadata: 
  global_client_id: 'gi1FcFBUSEX7c6srmZbgcR3m_IViva2F',
  persistent: {} }

```

As you can see the json is using simple quote and the properties does not have double double quotes.  
maybe this is the reason why I can not save the document properly.

---

<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/save-user-profile-data-using-rule-in-a-local-data-base/7175/4 "2018-03-02T05:54:49Z")

</div>


