Q:

what to pass as key instead of username and password for anonymous users in mongodb?

I am trying to make a mongodb schema in which i am allowing the person to publish projects anonymously, i already have the authenticated user schema and i am thinking of using that only to allow users to publish their projects! any idea on how should i proceed ?
for example : like what should be the authenticity for anonymous user, should it be a same key for all users, or different key for every user etc... i am fairly new to database and i am confused. any suggestions to me ?
schema user :
const UserSchema = new Schema({
  full_name: {
    type: String,
    required: true
  },
  username: {
    type: String,
    required: true
  },
  email: {
    type: String
  },
  password: {
    type: String,
    required: true
  },
  avatar: {
    type: String
  },
  date: {
    type: Date,
    default: Date.now
  },
  projects: [{ type: Schema.Types.ObjectId, ref: "projects" }]
});

thankyou

A:

Every document in mongodb has a unique _id field generated automatically, so you can use that field to identify every anonymous user.
My suggestion is to use cookies to authenticate the user, you can use a library like passport.js to validate the user and save its mongodb unique _id, so when this user sends a request to your server you can get its _id with something like this req.user._id.
One possible disadvantage is that when an anonymous user clears his cookies, he loses authentication and thus loses access to his projects.

