how to add sub collection to a document in firestore? [closed]

Your code should work if you change .set to .add. Cloud Firestore will then issue a new ID for that document. If you want to specify the document ID, then you'll need to do this...

Set a book with a given ID

db.collection('users').doc(this.username).collection('booksList').doc(myBookId).set({
  password: this.password,
  name: this.name,
  rollno: this.rollno
})

This page details how to Add data to Cloud Firestore

Add a book

db.collection('users').doc(this.username).collection('booksList').add({
  password: this.password,
  name: this.name,
  rollno: this.rollno
})