Warn when Realm.Types is still used

This commit is contained in:
Marius Rackwitz 2016-07-13 20:02:16 +02:00 committed by Ari Lazier
parent 9d25435105
commit 7755e7030b

View File

@ -41,18 +41,29 @@ if (typeof Realm != 'undefined') {
Object.defineProperties(realmConstructor.Collection.prototype, arrayMethods);
// TODO: Remove this now useless object.
var types = Object.freeze({
'BOOL': 'bool',
'INT': 'int',
'FLOAT': 'float',
'DOUBLE': 'double',
'STRING': 'string',
'DATE': 'date',
'DATA': 'data',
'OBJECT': 'object',
'LIST': 'list',
});
Object.defineProperty(realmConstructor, 'Types', {
value: Object.freeze({
'BOOL': 'bool',
'INT': 'int',
'FLOAT': 'float',
'DOUBLE': 'double',
'STRING': 'string',
'DATE': 'date',
'DATA': 'data',
'OBJECT': 'object',
'LIST': 'list',
})
get: function() {
var stack = new Error().stack.split("\n").slice(2).join("\n");
var msg = '`Realm.Types` is deprecated! Please specify the type name as lowercase string instead!\n'+stack;
if (console.warn != undefined) {
console.warn(msg);
}
else {
console.log(msg);
}
return types;
}
});
module.exports = realmConstructor;