import 'package:cloud_firestore/cloud_firestore.dart';
class ApiService{
final Firestore _db = Firestore.instance;
final String _path;
CollectionReference _ref;
ApiService(this._path) {
_ref = _db.collection(_path);
}
Future<QuerySnapshot> getDataCollection() {
return _ref.getDocuments();
}
Stream<QuerySnapshot> streamDataCollectionContains(
String field, dynamic value) {
return _ref
.orderBy(field, descending: false).startAt([value]).endAt([value+ '\uf8ff'])
.snapshots();
}
Stream<QuerySnapshot> streamDataCollectionWhere(
String field, dynamic value) {
return _ref
.where(field, isEqualTo: value)
.snapshots();
}
Stream<QuerySnapshot> streamDataCollection() {
return _ref.snapshots();
}
Stream<DocumentSnapshot> streamDataCollectionById(String id) {
return _ref.document(id).snapshots();
}
Future<DocumentSnapshot> getDocumentById(String id) {
return _ref.document(id).get();
}
Future<DocumentReference> create(Map data) {
return _ref.add(data);
}
Future<void> delete(String id) {
return _ref.document(id).delete();
}
Future<void> update(Map data, String id) {
return _ref.document(id).updateData(data);
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}