mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-10 14:25:58 +00:00
Improvements from PR feedback
This commit is contained in:
parent
3c657c3bbf
commit
cdcb99a502
@ -56,6 +56,13 @@ function setupRealm(realm, realmId) {
|
||||
});
|
||||
}
|
||||
|
||||
function getObjectType(realm, type) {
|
||||
if (typeof type == 'function') {
|
||||
return objects.typeForConstructor(realm[keys.realm], type);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
export default class Realm {
|
||||
constructor(config) {
|
||||
let schemas = typeof config == 'object' && config.schema;
|
||||
@ -90,30 +97,18 @@ export default class Realm {
|
||||
}
|
||||
|
||||
create(type, ...args) {
|
||||
if (typeof type == 'function') {
|
||||
type = objects.typeForConstructor(this[keys.realm], type);
|
||||
}
|
||||
|
||||
let method = util.createMethod(objectTypes.REALM, 'create', true);
|
||||
return method.apply(this, [type, ...args]);
|
||||
return method.apply(this, [getObjectType(this, type), ...args]);
|
||||
}
|
||||
|
||||
objects(type, ...args) {
|
||||
if (typeof type == 'function') {
|
||||
type = objects.typeForConstructor(this[keys.realm], type);
|
||||
}
|
||||
|
||||
let method = util.createMethod(objectTypes.REALM, 'objects');
|
||||
return method.apply(this, [type, ...args]);
|
||||
return method.apply(this, [getObjectType(this, type), ...args]);
|
||||
}
|
||||
|
||||
objectForPrimaryKey(type, ...args) {
|
||||
if (typeof type == 'function') {
|
||||
type = objects.typeForConstructor(this[keys.realm], type);
|
||||
}
|
||||
|
||||
let method = util.createMethod(objectTypes.REALM, 'objectForPrimaryKey');
|
||||
return method.apply(this, [type, ...args]);
|
||||
return method.apply(this, [getObjectType(this, type), ...args]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,6 @@ public:
|
||||
return name;
|
||||
}
|
||||
|
||||
// converts constructor object or type name to type name
|
||||
static const ObjectSchema& validated_object_schema_for_value(ContextType ctx, const SharedRealm &realm, const ValueType &value) {
|
||||
std::string object_type;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user