-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into realm_compact_on_open
- Loading branch information
Showing
16 changed files
with
570 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
// ************************************************************************** | ||
// RealmObjectGenerator | ||
// ************************************************************************** | ||
|
||
class Fooo extends _Foo with RealmEntity, RealmObject { | ||
static var _defaultsSet = false; | ||
|
||
Fooo({ | ||
int x = 0, | ||
}) { | ||
if (!_defaultsSet) { | ||
_defaultsSet = RealmObject.setDefaults<Fooo>({ | ||
'x': 0, | ||
}); | ||
} | ||
RealmObject.set(this, 'x', x); | ||
} | ||
|
||
Fooo._(); | ||
|
||
@override | ||
int get x => RealmObject.get<int>(this, 'x') as int; | ||
@override | ||
set x(int value) => RealmObject.set(this, 'x', value); | ||
|
||
@override | ||
Stream<RealmObjectChanges<Fooo>> get changes => | ||
RealmObject.getChanges<Fooo>(this); | ||
|
||
static SchemaObject get schema => _schema ??= _initSchema(); | ||
static SchemaObject? _schema; | ||
static SchemaObject _initSchema() { | ||
RealmObject.registerFactory(Fooo._); | ||
return const SchemaObject(Fooo, [ | ||
SchemaProperty('x', RealmPropertyType.int), | ||
]); | ||
} | ||
} | ||
|
||
class Bar extends _Bar with RealmEntity, RealmObject { | ||
static var _defaultsSet = false; | ||
|
||
Bar( | ||
String id, | ||
bool aBool, | ||
bool another, | ||
ObjectId objectId, { | ||
Uint8List data = Uint8List(16), | ||
DateTime timestamp = DateTime.now(), | ||
double aDouble = 0.0, | ||
Foo? foo, | ||
String? anOptionalString, | ||
Iterable<int> list = const [], | ||
}) { | ||
if (!_defaultsSet) { | ||
_defaultsSet = RealmObject.setDefaults<Bar>({ | ||
'data': Uint8List(16), | ||
'timestamp': DateTime.now(), | ||
'aDouble': 0.0, | ||
}); | ||
} | ||
RealmObject.set(this, 'id', id); | ||
RealmObject.set(this, 'aBool', aBool); | ||
RealmObject.set(this, 'another', another); | ||
RealmObject.set(this, 'data', data); | ||
RealmObject.set(this, 'timestamp', timestamp); | ||
RealmObject.set(this, 'aDouble', aDouble); | ||
RealmObject.set(this, 'foo', foo); | ||
RealmObject.set(this, 'anOptionalString', anOptionalString); | ||
RealmObject.set(this, 'objectId', objectId); | ||
RealmObject.set<RealmList<int>>(this, 'list', RealmList<int>(list)); | ||
} | ||
|
||
Bar._(); | ||
|
||
@override | ||
String get id => RealmObject.get<String>(this, 'id') as String; | ||
@override | ||
set id(String value) => throw RealmUnsupportedSetError(); | ||
|
||
@override | ||
bool get aBool => RealmObject.get<bool>(this, 'aBool') as bool; | ||
@override | ||
set aBool(bool value) => RealmObject.set(this, 'aBool', value); | ||
|
||
@override | ||
bool get another => RealmObject.get<bool>(this, 'another') as bool; | ||
@override | ||
set another(bool value) => RealmObject.set(this, 'another', value); | ||
|
||
@override | ||
Uint8List get data => RealmObject.get<Uint8List>(this, 'data') as Uint8List; | ||
@override | ||
set data(Uint8List value) => RealmObject.set(this, 'data', value); | ||
|
||
@override | ||
DateTime get timestamp => | ||
RealmObject.get<DateTime>(this, 'tidspunkt') as DateTime; | ||
@override | ||
set timestamp(DateTime value) => RealmObject.set(this, 'tidspunkt', value); | ||
|
||
@override | ||
double get aDouble => RealmObject.get<double>(this, 'aDouble') as double; | ||
@override | ||
set aDouble(double value) => RealmObject.set(this, 'aDouble', value); | ||
|
||
@override | ||
Foo? get foo => RealmObject.get<Foo>(this, 'foo') as Foo?; | ||
@override | ||
set foo(covariant Foo? value) => RealmObject.set(this, 'foo', value); | ||
|
||
@override | ||
RealmList<int> get list => | ||
RealmObject.get<int>(this, 'list') as RealmList<int>; | ||
@override | ||
set list(covariant RealmList<int> value) => throw RealmUnsupportedSetError(); | ||
|
||
@override | ||
String? get anOptionalString => | ||
RealmObject.get<String>(this, 'anOptionalString') as String?; | ||
@override | ||
set anOptionalString(String? value) => | ||
RealmObject.set(this, 'anOptionalString', value); | ||
|
||
@override | ||
ObjectId get objectId => | ||
RealmObject.get<ObjectId>(this, 'objectId') as ObjectId; | ||
@override | ||
set objectId(ObjectId value) => RealmObject.set(this, 'objectId', value); | ||
|
||
@override | ||
Stream<RealmObjectChanges<Bar>> get changes => | ||
RealmObject.getChanges<Bar>(this); | ||
|
||
static SchemaObject get schema => _schema ??= _initSchema(); | ||
static SchemaObject? _schema; | ||
static SchemaObject _initSchema() { | ||
RealmObject.registerFactory(Bar._); | ||
return const SchemaObject(Bar, [ | ||
SchemaProperty('id', RealmPropertyType.string, primaryKey: true), | ||
SchemaProperty('aBool', RealmPropertyType.bool), | ||
SchemaProperty('another', RealmPropertyType.bool), | ||
SchemaProperty('data', RealmPropertyType.binary), | ||
SchemaProperty('tidspunkt', RealmPropertyType.timestamp, | ||
mapTo: 'tidspunkt'), | ||
SchemaProperty('aDouble', RealmPropertyType.double), | ||
SchemaProperty('foo', RealmPropertyType.object, | ||
optional: true, linkTarget: 'Foo'), | ||
SchemaProperty('list', RealmPropertyType.int, | ||
collectionType: RealmCollectionType.list), | ||
SchemaProperty('anOptionalString', RealmPropertyType.string, | ||
optional: true), | ||
SchemaProperty('objectId', RealmPropertyType.objectid), | ||
]); | ||
} | ||
} | ||
|
||
class PrimitiveTypes extends _PrimitiveTypes with RealmEntity, RealmObject { | ||
PrimitiveTypes( | ||
String stringProp, | ||
bool boolProp, | ||
DateTime dateProp, | ||
double doubleProp, | ||
ObjectId objectIdProp, | ||
) { | ||
RealmObject.set(this, 'stringProp', stringProp); | ||
RealmObject.set(this, 'boolProp', boolProp); | ||
RealmObject.set(this, 'dateProp', dateProp); | ||
RealmObject.set(this, 'doubleProp', doubleProp); | ||
RealmObject.set(this, 'objectIdProp', objectIdProp); | ||
} | ||
|
||
PrimitiveTypes._(); | ||
|
||
@override | ||
String get stringProp => | ||
RealmObject.get<String>(this, 'stringProp') as String; | ||
@override | ||
set stringProp(String value) => RealmObject.set(this, 'stringProp', value); | ||
|
||
@override | ||
bool get boolProp => RealmObject.get<bool>(this, 'boolProp') as bool; | ||
@override | ||
set boolProp(bool value) => RealmObject.set(this, 'boolProp', value); | ||
|
||
@override | ||
DateTime get dateProp => | ||
RealmObject.get<DateTime>(this, 'dateProp') as DateTime; | ||
@override | ||
set dateProp(DateTime value) => RealmObject.set(this, 'dateProp', value); | ||
|
||
@override | ||
double get doubleProp => | ||
RealmObject.get<double>(this, 'doubleProp') as double; | ||
@override | ||
set doubleProp(double value) => RealmObject.set(this, 'doubleProp', value); | ||
|
||
@override | ||
ObjectId get objectIdProp => | ||
RealmObject.get<ObjectId>(this, 'objectIdProp') as ObjectId; | ||
@override | ||
set objectIdProp(ObjectId value) => | ||
RealmObject.set(this, 'objectIdProp', value); | ||
|
||
@override | ||
Stream<RealmObjectChanges<PrimitiveTypes>> get changes => | ||
RealmObject.getChanges<PrimitiveTypes>(this); | ||
|
||
static SchemaObject get schema => _schema ??= _initSchema(); | ||
static SchemaObject? _schema; | ||
static SchemaObject _initSchema() { | ||
RealmObject.registerFactory(PrimitiveTypes._); | ||
return const SchemaObject(PrimitiveTypes, [ | ||
SchemaProperty('stringProp', RealmPropertyType.string), | ||
SchemaProperty('boolProp', RealmPropertyType.bool), | ||
SchemaProperty('dateProp', RealmPropertyType.timestamp), | ||
SchemaProperty('doubleProp', RealmPropertyType.double), | ||
SchemaProperty('objectIdProp', RealmPropertyType.objectid), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:realm_common/realm_common.dart'; | ||
|
||
@RealmModel() | ||
class _IntPK { | ||
@PrimaryKey() | ||
late int id; | ||
} | ||
@RealmModel() | ||
class _StringPK { | ||
@PrimaryKey() | ||
late String id; | ||
} | ||
|
||
@RealmModel() | ||
class _ObjectIdPK { | ||
@PrimaryKey() | ||
late ObjectId id; | ||
} |
Oops, something went wrong.