final databaseReference = Firestore.instance;
void createRecord() async {
Map data = {'length': '1:30:20', 'position': '1', 'title': 'Introduction 3.'};
await databaseReference
.collection("class_10")
.document('chapter_4')
.collection('videos')
.document()
.setData(
data
);
// await databaseReference.collection("classes")
// .document('10')
// .collection('chapter')
// .document('1')
// .collection('videos')
// .document('1')
// .setData({
// 'title': 'Introduction 1 Sets',
// 'length': '10:20'
// });
}
void getData() {
databaseReference
.collection("class_10")
.document('chapter_1')
.collection('videos')
.getDocuments()
.then((QuerySnapshot snapshot) {
snapshot.documents.forEach((f) => print('${f.data}}'));
});
}
void updateData() {
try {
databaseReference
.collection('books')
.document('1')
.updateData({'description': 'Head First Flutter'});
} catch (e) {
print(e.toString());
}
databaseReference
.collection("classes")
.document('10')
.collection('chapter')
.document('1')
.collection('videos');
}
void deleteData() {
try {
databaseReference.collection('books').document('1').delete();
} catch (e) {
print(e.toString());
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter