create method
To Write in firestore database
call create method from your model like this:
user.create();
if you have docId
for doc:
user.create(docId: 'doc_id');
return model after create
Implementation
Future<T?> create({String? docId}) async {
if (docId != null) {
return await _collectionReference
.doc(docId)
.set(this)
.then((value) async => await find(docId));
}
return await _collectionReference
.add(this)
.then((doc) async => _toModel(await doc.get()));
}