Home > Software design >  How to auto-generate Username from email, first name and last name in JavaScript?
How to auto-generate Username from email, first name and last name in JavaScript?

Time:10-15

I want to create a username from the user's email, first name, and the last name entered. I am using NodeJs and Sequelize. I want to make it unique by continuously checking the database. How can I achieve this?

CodePudding user response:

There can be multiple ways to achieve the solution of your problem .One way to achieve is you can use timestamp in conjunction with email, first name, and the last name.

CodePudding user response:

There are many ways to achieve this.

  1. One way to create pre and post-middleware.

  2. Way use timestamp.

  3. In the schema data field added.

    { timestamps: true }

  • Related