2016-02-18 19:59:34 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright 2016 Realm Inc.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
2015-08-14 15:18:49 +00:00
|
|
|
|
2015-08-13 16:12:48 +00:00
|
|
|
'use strict';
|
|
|
|
|
2017-06-29 09:59:10 +00:00
|
|
|
const Realm = require('realm');
|
|
|
|
|
2015-10-14 21:58:42 +00:00
|
|
|
exports.TestObject = {
|
2015-10-30 19:08:31 +00:00
|
|
|
name: 'TestObject',
|
|
|
|
properties: {
|
2016-07-13 16:53:47 +00:00
|
|
|
doubleCol: 'double',
|
2015-10-30 19:08:31 +00:00
|
|
|
}
|
2015-08-13 16:12:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
function PersonObject() {}
|
2016-02-18 19:09:51 +00:00
|
|
|
PersonObject.schema = {
|
2015-10-30 19:08:31 +00:00
|
|
|
name: 'PersonObject',
|
|
|
|
properties: {
|
2017-06-29 09:59:10 +00:00
|
|
|
name: 'string',
|
|
|
|
age: 'double',
|
2017-09-11 21:57:31 +00:00
|
|
|
married: {type: 'bool', default: false},
|
2017-06-29 09:59:10 +00:00
|
|
|
children: {type: 'list', objectType: 'PersonObject'},
|
|
|
|
parents: {type: 'linkingObjects', objectType: 'PersonObject', property: 'children'},
|
2015-10-30 19:08:31 +00:00
|
|
|
}
|
2015-08-13 16:12:48 +00:00
|
|
|
};
|
|
|
|
PersonObject.prototype.description = function() {
|
|
|
|
return this.name + ' ' + this.age;
|
|
|
|
};
|
2016-02-29 05:40:27 +00:00
|
|
|
PersonObject.prototype.toString = function() {
|
|
|
|
return this.name;
|
|
|
|
};
|
2017-08-09 13:08:19 +00:00
|
|
|
PersonObject.__proto__ = Realm.Object;
|
|
|
|
PersonObject.prototype.__proto__ = Realm.Object.prototype;
|
2015-10-02 21:57:54 +00:00
|
|
|
exports.PersonObject = PersonObject;
|
2015-08-13 16:12:48 +00:00
|
|
|
|
2016-02-18 21:41:11 +00:00
|
|
|
exports.PersonList = {
|
|
|
|
name: 'PersonList',
|
|
|
|
properties: {
|
2017-09-11 21:57:31 +00:00
|
|
|
list: 'PersonObject[]',
|
2016-02-18 21:41:11 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-10-14 21:58:42 +00:00
|
|
|
exports.BasicTypes = {
|
2015-08-13 16:12:48 +00:00
|
|
|
name: 'BasicTypesObject',
|
2015-10-30 19:08:31 +00:00
|
|
|
properties: {
|
2016-07-13 16:53:47 +00:00
|
|
|
boolCol: 'bool',
|
|
|
|
intCol: 'int',
|
|
|
|
floatCol: 'float',
|
|
|
|
doubleCol: 'double',
|
|
|
|
stringCol: 'string',
|
|
|
|
dateCol: 'date',
|
|
|
|
dataCol: 'data',
|
2015-10-30 19:08:31 +00:00
|
|
|
}
|
2015-08-13 16:12:48 +00:00
|
|
|
};
|
|
|
|
|
2017-09-11 21:57:31 +00:00
|
|
|
exports.AllTypes = {
|
|
|
|
name: 'AllTypesObject',
|
|
|
|
properties: {
|
|
|
|
boolCol: 'bool',
|
|
|
|
intCol: 'int',
|
|
|
|
floatCol: 'float',
|
|
|
|
doubleCol: 'double',
|
|
|
|
stringCol: 'string',
|
|
|
|
dateCol: 'date',
|
|
|
|
dataCol: 'data',
|
|
|
|
objectCol: 'TestObject',
|
|
|
|
|
|
|
|
optBoolCol: 'bool?',
|
|
|
|
optIntCol: 'int?',
|
|
|
|
optFloatCol: 'float?',
|
|
|
|
optDoubleCol: 'double?',
|
|
|
|
optStringCol: 'string?',
|
|
|
|
optDateCol: 'date?',
|
|
|
|
optDataCol: 'data?',
|
|
|
|
|
|
|
|
boolArrayCol: 'bool[]',
|
|
|
|
intArrayCol: 'int[]',
|
|
|
|
floatArrayCol: 'float[]',
|
|
|
|
doubleArrayCol: 'double[]',
|
|
|
|
stringArrayCol: 'string[]',
|
|
|
|
dateArrayCol: 'date[]',
|
|
|
|
dataArrayCol: 'data[]',
|
|
|
|
objectArrayCol: 'TestObject[]',
|
|
|
|
|
|
|
|
optBoolArrayCol: 'bool?[]',
|
|
|
|
optIntArrayCol: 'int?[]',
|
|
|
|
optFloatArrayCol: 'float?[]',
|
|
|
|
optDoubleArrayCol: 'double?[]',
|
|
|
|
optStringArrayCol: 'string?[]',
|
|
|
|
optDateArrayCol: 'date?[]',
|
|
|
|
optDataArrayCol: 'data?[]',
|
|
|
|
|
|
|
|
linkingObjectsCol: {type: 'linkingObjects', objectType: 'LinkToAllTypesObject', property: 'allTypesCol'},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.AllPrimaryTypes = {
|
|
|
|
name: 'AllPrimaryTypesObject',
|
|
|
|
primaryKey: 'primaryCol',
|
2015-10-30 19:08:31 +00:00
|
|
|
properties: {
|
2017-09-11 21:57:31 +00:00
|
|
|
primaryCol: 'string',
|
|
|
|
boolCol: 'bool',
|
|
|
|
intCol: 'int',
|
|
|
|
floatCol: 'float',
|
|
|
|
doubleCol: 'double',
|
|
|
|
stringCol: 'string',
|
|
|
|
dateCol: 'date',
|
|
|
|
dataCol: 'data',
|
|
|
|
objectCol: 'TestObject',
|
|
|
|
arrayCol: {type: 'list', objectType: 'TestObject'},
|
2015-10-30 19:08:31 +00:00
|
|
|
}
|
2015-10-22 03:36:21 +00:00
|
|
|
};
|
|
|
|
|
2017-09-11 21:57:31 +00:00
|
|
|
exports.LinkToAllTypes = {
|
|
|
|
name: 'LinkToAllTypesObject',
|
|
|
|
properties: {
|
|
|
|
allTypesCol: 'AllTypesObject',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-28 19:16:16 +00:00
|
|
|
exports.IndexedTypes = {
|
|
|
|
name: 'IndexedTypesObject',
|
|
|
|
properties: {
|
2017-09-11 21:57:31 +00:00
|
|
|
boolCol: {type: 'bool', indexed: true},
|
|
|
|
intCol: {type: 'int', indexed: true},
|
|
|
|
stringCol: {type: 'string', indexed: true},
|
|
|
|
dateCol: {type: 'date', indexed: true},
|
|
|
|
optBoolCol: {type: 'bool?', indexed: true},
|
|
|
|
optIntCol: {type: 'int?', indexed: true},
|
|
|
|
optStringCol: {type: 'string?', indexed: true},
|
|
|
|
optDateCol: {type: 'date?', indexed: true},
|
2016-04-28 19:16:16 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-10-14 21:58:42 +00:00
|
|
|
exports.LinkTypes = {
|
2015-08-13 16:12:48 +00:00
|
|
|
name: 'LinkTypesObject',
|
2015-10-30 19:08:31 +00:00
|
|
|
properties: {
|
2017-09-11 21:57:31 +00:00
|
|
|
objectCol: 'TestObject',
|
2016-07-13 16:53:47 +00:00
|
|
|
objectCol1: {type: 'object', objectType: 'TestObject'},
|
2017-09-11 21:57:31 +00:00
|
|
|
arrayCol: 'TestObject[]',
|
|
|
|
arrayCol1: {type: 'list', objectType: 'TestObject'},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.PrimitiveArrays = {
|
|
|
|
name: 'PrimitiveArrays',
|
|
|
|
properties: {
|
|
|
|
bool: 'bool[]',
|
|
|
|
int: 'int[]',
|
|
|
|
float: 'float[]',
|
|
|
|
double: 'double[]',
|
|
|
|
string: 'string[]',
|
|
|
|
date: 'date[]',
|
|
|
|
data: 'data[]',
|
|
|
|
|
|
|
|
optBool: 'bool?[]',
|
|
|
|
optInt: 'int?[]',
|
|
|
|
optFloat: 'float?[]',
|
|
|
|
optDouble: 'double?[]',
|
|
|
|
optString: 'string?[]',
|
|
|
|
optDate: 'date?[]',
|
|
|
|
optData: 'data?[]',
|
2015-10-30 19:08:31 +00:00
|
|
|
}
|
2015-08-13 16:12:48 +00:00
|
|
|
};
|
2015-09-03 21:05:56 +00:00
|
|
|
|
2015-10-14 21:58:42 +00:00
|
|
|
exports.IntPrimary = {
|
2015-10-30 19:08:31 +00:00
|
|
|
name: 'IntPrimaryObject',
|
|
|
|
primaryKey: 'primaryCol',
|
|
|
|
properties: {
|
2016-07-13 16:53:47 +00:00
|
|
|
primaryCol: 'int',
|
|
|
|
valueCol: 'string',
|
2015-10-30 19:08:31 +00:00
|
|
|
}
|
2015-09-03 21:05:56 +00:00
|
|
|
};
|
|
|
|
|
2016-06-03 23:43:36 +00:00
|
|
|
exports.StringPrimary = {
|
|
|
|
name: 'StringPrimaryObject',
|
|
|
|
primaryKey: 'primaryCol',
|
|
|
|
properties: {
|
2016-07-13 16:53:47 +00:00
|
|
|
primaryCol: 'string',
|
|
|
|
valueCol: 'int',
|
2016-06-03 23:43:36 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-08-18 12:22:29 +00:00
|
|
|
exports.StringOnly = {
|
|
|
|
name: 'StringOnlyObject',
|
|
|
|
properties: {
|
|
|
|
stringCol: 'string',
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-10-14 21:58:42 +00:00
|
|
|
exports.DefaultValues = {
|
2015-10-30 19:08:31 +00:00
|
|
|
name: 'DefaultValuesObject',
|
|
|
|
properties: {
|
2017-09-11 21:57:31 +00:00
|
|
|
boolCol: {type: 'bool', default: true},
|
|
|
|
intCol: {type: 'int', default: -1},
|
|
|
|
floatCol: {type: 'float', default: -1.1},
|
|
|
|
doubleCol: {type: 'double', default: -1.11},
|
|
|
|
stringCol: {type: 'string', default: 'defaultString'},
|
|
|
|
dateCol: {type: 'date', default: new Date(1.111)},
|
|
|
|
dataCol: {type: 'data', default: new ArrayBuffer(1)},
|
|
|
|
objectCol: {type: 'TestObject', default: {doubleCol: 1}},
|
|
|
|
nullObjectCol: {type: 'TestObject', default: null},
|
|
|
|
arrayCol: {type: 'TestObject[]', default: [{doubleCol: 2}]},
|
2015-10-30 19:08:31 +00:00
|
|
|
}
|
2015-09-04 22:43:26 +00:00
|
|
|
};
|
2015-11-16 23:05:50 +00:00
|
|
|
|
|
|
|
exports.QueryObject = {
|
|
|
|
name: 'QueryObject',
|
|
|
|
properties: [
|
2016-07-13 16:53:47 +00:00
|
|
|
{name: 'bool1', type: 'bool'},
|
|
|
|
{name: 'bool2', type: 'bool'},
|
|
|
|
{name: 'int1', type: 'int'},
|
|
|
|
{name: 'int2', type: 'int'},
|
|
|
|
{name: 'float1', type: 'float'},
|
|
|
|
{name: 'float2', type: 'float'},
|
|
|
|
{name: 'double1', type: 'double'},
|
|
|
|
{name: 'double2', type: 'double'},
|
|
|
|
{name: 'string1', type: 'string'},
|
|
|
|
{name: 'string2', type: 'string'},
|
2015-11-16 23:05:50 +00:00
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.NullQueryObject = {
|
|
|
|
name: 'NullQueryObject',
|
|
|
|
properties: [
|
2016-07-13 16:53:47 +00:00
|
|
|
{name: 'bool1', type: 'bool'},
|
|
|
|
{name: 'bool2', type: 'bool'},
|
|
|
|
{name: 'int1', type: 'int'},
|
|
|
|
{name: 'int2', type: 'int'},
|
|
|
|
{name: 'float1', type: 'float'},
|
|
|
|
{name: 'float2', type: 'float'},
|
|
|
|
{name: 'double1', type: 'double'},
|
|
|
|
{name: 'double2', type: 'double'},
|
|
|
|
{name: 'string1', type: 'string'},
|
|
|
|
{name: 'string2', type: 'string'},
|
2015-11-16 23:05:50 +00:00
|
|
|
]
|
|
|
|
};
|
2016-05-13 22:29:59 +00:00
|
|
|
|
2017-09-30 08:26:42 +00:00
|
|
|
exports.NullableBasicTypes = {
|
|
|
|
name: 'NullableBasicTypesObject',
|
|
|
|
properties: [
|
|
|
|
{name: 'boolCol', type: 'bool?'},
|
|
|
|
{name: 'intCol', type: 'int?'},
|
|
|
|
{name: 'floatCol', type: 'float?'},
|
|
|
|
{name: 'doubleCol', type: 'double?'},
|
|
|
|
{name: 'stringCol', type: 'string?'},
|
|
|
|
{name: 'dateCol', type: 'date?'},
|
|
|
|
{name: 'dataCol', type: 'data?'},
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2016-05-13 22:29:59 +00:00
|
|
|
exports.DateObject = {
|
|
|
|
name: 'Date',
|
|
|
|
properties: {
|
2016-05-26 20:17:19 +00:00
|
|
|
currentDate: 'date',
|
2017-09-11 21:57:31 +00:00
|
|
|
nullDate: 'date?'
|
2016-05-13 22:29:59 +00:00
|
|
|
}
|
|
|
|
};
|
2017-06-29 09:59:10 +00:00
|
|
|
|
|
|
|
exports.LinkingObjectsObject = {
|
|
|
|
name: 'LinkingObjectsObject',
|
|
|
|
properties: {
|
|
|
|
value: 'int',
|
2017-09-11 21:57:31 +00:00
|
|
|
links: 'LinkingObjectsObject[]',
|
2017-06-29 09:59:10 +00:00
|
|
|
linkingObjects: {type: 'linkingObjects', objectType: 'LinkingObjectsObject', property: 'links'}
|
|
|
|
}
|
2018-02-20 13:43:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.ParentObject = {
|
|
|
|
name: 'ParentObject',
|
|
|
|
properties: {
|
|
|
|
id: 'int',
|
|
|
|
name: 'NameObject[]'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.NameObject = {
|
|
|
|
name: 'NameObject',
|
|
|
|
properties: {
|
|
|
|
family: 'string',
|
|
|
|
given: 'string[]',
|
|
|
|
prefix: 'string[]'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.MultiListObject = {
|
|
|
|
name: 'MultiListObject',
|
|
|
|
properties: {
|
|
|
|
'id': 'int',
|
|
|
|
'list1': 'string[]',
|
|
|
|
'list2': 'string[]'
|
|
|
|
}
|
|
|
|
};
|
2018-04-03 09:48:33 +00:00
|
|
|
|
|
|
|
exports.Language = {
|
|
|
|
name: 'Language',
|
|
|
|
properties: {
|
|
|
|
name: 'string',
|
|
|
|
spokenIn: {type: 'linkingObjects', objectType: 'Country', property: 'languages'}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.Country = {
|
|
|
|
name: 'Country',
|
|
|
|
properties: {
|
|
|
|
name: 'string',
|
|
|
|
languages: 'Language[]',
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|