diameter/lib/models/x_user.dart

47 lines
828 B
Dart

import 'package:diameter/main.dart';
import 'package:objectbox/objectbox.dart';
// @Entity()
// @Sync()
class User {
static final Box<User> box = objectBox.store.box<User>();
// properties
int id;
bool deleted;
String name;
String email;
String password;
// constructor
User({
this.id = 0,
this.deleted = false,
required this.name,
required this.email,
required this.password,
});
// methods
static User? get(int id) => box.get(id);
static void put(User user) => box.put(user);
// static String login(String name, String password) {
// password.h
// return
// }
static void remove(int id) {
final item = box.get(id);
if (item != null) {
item.deleted = true;
box.put(item);
}
}
@override
String toString() {
return name;
}
}