ObjectBox
This commit is contained in:
1 parent
f8317be627
commit
809bffc7a2
9 files changed
+125
-42
No files matched your search
+8
-4
@@ -1,13 +1,16 @@
|
||||
import 'dart:convert';
|
||||
import 'package:dart_mq/dart_mq.dart';
|
||||
import 'package:objectbox/objectbox.dart';
|
||||
import 'package:stadtbote/model/job_tour.dart';
|
||||
|
||||
@Entity()
|
||||
class Job with ProducerMixin {
|
||||
class Job {
|
||||
@Id()
|
||||
int id = 0;
|
||||
|
||||
// External ID from server
|
||||
@Unique()
|
||||
late int externalId;
|
||||
|
||||
late String ver;
|
||||
late int state;
|
||||
String? crFilter;
|
||||
@@ -35,7 +38,8 @@ class Job with ProducerMixin {
|
||||
|
||||
factory Job.fromJson(Map<String, dynamic> json) {
|
||||
final job = Job();
|
||||
job.id = json['id'] as int? ?? 0;
|
||||
job.id = 0; // Let ObjectBox assign the ID
|
||||
job.externalId = json['id'] as int; // Store external ID separately
|
||||
job.ver = json['ver'] as String;
|
||||
job.state = json['state'] as int;
|
||||
job.crFilter = json['cr_filter'] as String?;
|
||||
@@ -53,7 +57,7 @@ class Job with ProducerMixin {
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'id': externalId, // Use external ID for JSON
|
||||
'ver': ver,
|
||||
'state': state,
|
||||
'cr_filter': crFilter,
|
||||
|
||||
Reference in new issue
Block a user