Can I use 'objectId' as a user id on my app?

I am trying to create a custom signup process where I need an unique and constant value to identify the user. To be more specific, the value is appended to @tempmail.com to generate the user mail.
Thus I can have the user get on board with MetaMask.

My question is what field on user database is constant and unique? Among those on _User table, i’m guessing objectId is the one I should refer to.

If the ethAddress is constant regardless the chain selected, I prefer to use it since ethAddress is provided via MetaMask. Fetching objectId from Moralis Id is more time consuming, right?

Any advices appreciated.
Thanks.

The objectId is a unique field in the DB. Fetching data from the DB using the objectId is the easiest and requires less logic which you can find an example here

1 Like
  1. As long as data is not deleted from DB, objectID is immutable. And Fetching by ID in DB does not take long.
  2. Irrespective of the ethAddress chain selection. If you look at the example using Metamask, the addresses are all the same because it uses the EVM chain.
1 Like

Thanks for the response. Does the ethAddress remain the same even when I change it from Testnet to Mainnet? Because I assume the ethAddress is fetched when MetaMask is connected to Moralis. What if the account is deleted from the MetaMask, is it still in the Moralis db?

Does the ethAddress remain the same even when I change it from Testnet to Mainnet?

Yes, the address comes from the current connected wallet (from MetaMask).

What if the account is deleted from the MetaMask, is it still in the Moralis db?

Yes, unless you delete the user yourself from the DB.

1 Like

Correct. ethAddress is immutable.

1 Like