Combining Different User Schemas Based on Provider Property

hi, is it possible to do this in same schema?, i dont want to create two different schema, i want it to both inside same schema, and differentiator is the provider property
const userWithEmailProvider = {
  provider: 'email',
  details: {
    name: 'John Doe',
    email: 'johndoe@example.com',
    password: 'password',
  }
}

const userWithSocialProvider = {
  provider: 'google', // anything other than 'email'
  details: {
    name: 'John Doe',
    email: 'johndoe@example.com',
    id: 'some-id',
    avatar_url: 'https://example.com/avatar.jpg',
    token: {
      value: '',
      refresh_token: undefined,
      token_secret: undefined,
      expires_at: undefined, // (uxon) DateTime <-> Date
      expires_in: undefined
    }
  }
}
Was this page helpful?