-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathcollection.dart
77 lines (64 loc) · 2.21 KB
/
collection.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
part of '../../models.dart';
/// Collection
class Collection implements Model {
/// Collection ID.
final String $id;
/// Collection creation date in ISO 8601 format.
final String $createdAt;
/// Collection update date in ISO 8601 format.
final String $updatedAt;
/// Collection permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
final List<String> $permissions;
/// Database ID.
final String databaseId;
/// Collection name.
final String name;
/// Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the collection is inaccessible to users, but remains accessible to Server SDKs using API keys.
final bool enabled;
/// Whether document-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions).
final bool documentSecurity;
/// Collection attributes.
final List attributes;
/// Collection indexes.
final List<Index> indexes;
Collection({
required this.$id,
required this.$createdAt,
required this.$updatedAt,
required this.$permissions,
required this.databaseId,
required this.name,
required this.enabled,
required this.documentSecurity,
required this.attributes,
required this.indexes,
});
factory Collection.fromMap(Map<String, dynamic> map) {
return Collection(
$id: map['\$id'].toString(),
$createdAt: map['\$createdAt'].toString(),
$updatedAt: map['\$updatedAt'].toString(),
$permissions: List.from(map['\$permissions'] ?? []),
databaseId: map['databaseId'].toString(),
name: map['name'].toString(),
enabled: map['enabled'],
documentSecurity: map['documentSecurity'],
attributes: List.from(map['attributes'] ?? []),
indexes: List<Index>.from(map['indexes'].map((p) => Index.fromMap(p))),
);
}
Map<String, dynamic> toMap() {
return {
"\$id": $id,
"\$createdAt": $createdAt,
"\$updatedAt": $updatedAt,
"\$permissions": $permissions,
"databaseId": databaseId,
"name": name,
"enabled": enabled,
"documentSecurity": documentSecurity,
"attributes": attributes,
"indexes": indexes.map((p) => p.toMap()).toList(),
};
}
}