DataBase.dart 893 B

1234567891011121314151617181920212223242526272829303132
  1. import 'package:database/sql.dart';
  2. import 'package:database_adapter_sqlite/database_adapter_sqlite.dart';
  3. import 'package:taskservice/Model/JXMemberModel.dart';
  4. import 'package:taskservice/Model/JXServiceModel.dart';
  5. class MyDataBase {
  6. SqlClient _database;
  7. SqlClientTableHelper _memberHelper;
  8. SqlClientTableHelper _serviceHelper;
  9. static MyDataBase _instance;
  10. MyDataBase() {
  11. _database = SQLite(path: 'path/to/database.db',).database().sqlClient;
  12. _memberHelper = _database.table('members');
  13. _serviceHelper = _database.table('services');
  14. }
  15. static MyDataBase getInstance(){
  16. if(_instance == null) _instance = MyDataBase();
  17. return _instance;
  18. }
  19. Future<void> saveMember(JXMemberModel jxMemberModel) async {
  20. _memberHelper.insert(jxMemberModel.toMap());
  21. }
  22. Future<void> saveService(JXMemberModel jxMemberModel, JXServiceModel jxServiceModel) {
  23. }
  24. }