-
Type: Task
-
Resolution: Fixed
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
2977
-
SDK FY21-Q2
Goals
Use named linked objects in SUBQUERY.
Expected Results
It works.
Actual Results
Throws error.
Unable to find source-code formatter for language: ts. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
Error: No property 'items' on object of type 'CollectionModel'
Steps to Reproduce
We query TransferCollectionModel which has sourceCollections that is CollectionModel[] and each CollectionModel has items linking object for CollectionItemModel.
So:
- TransferCollectionModel has list of
- CollectionModel which has linking object to
- CollectionItemModel with foreign key collection pointing to CollectionModel
- CollectionModel which has linking object to
Try to use this query in the filtered function.
SUBQUERY(sourceCollections, $sourceCollection, $sourceCollection.items.@count == 0 && $sourceCollection.lastFetchedAt != null).@count > 0)
and it will throw an error.
However:
SUBQUERY(sourceCollections, $sourceCollection, $sourceCollection.@links.CollectionItemModel.collection.@count == 0 && $sourceCollection.lastFetchedAt != null).@count > 0)
works.
So the linking objects are working in subquery but somehow it does not recognise named linking object.
Code Sample
CollectionItemModel schema:
Unable to find source-code formatter for language: ts. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
export class CollectionItemModel extends BaseModel { public static schema = { ...BaseModel.schema, name: 'CollectionItemModel', primaryKey: 'id', properties: { ...BaseModel.schema.properties, id: 'string', name: 'string', album: 'string', artist: 'string', position: { type: 'int', default: 0 }, additionalDataString: 'string?', imageUrl: 'string?', collection: 'CollectionModel', deletedAt: 'int?' } };
CollectionModel schema:
Unable to find source-code formatter for language: ts. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
export class CollectionModel extends BaseModel { public static schema = { ...BaseModel.schema, name: 'CollectionModel', primaryKey: 'id', properties: { ...BaseModel.schema.properties, id: 'string', name: 'string', itemCount: 'int?', type: { type: 'int', default: CollectionType.PLAYLIST }, additionalDataString: 'string?', authenticationModel: 'ImporterAuthenticationModel', items: { type: 'linkingObjects', objectType: 'CollectionItemModel', property: 'collection' }, lastFetchedAt: 'int?' } };
TransferCollectionModel schema:
Unable to find source-code formatter for language: ts. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
export class TransferCollectionModel extends BaseModel { public static schema = { ...BaseModel.schema, name: 'TransferCollectionModel', primaryKey: 'id', properties: { ...BaseModel.schema.properties, id: 'string', fromCollection: 'CollectionModel', toCollection: 'CollectionModel?', sourceCollections: 'CollectionModel[]', targetCollections: 'CollectionModel[]', status: { type: 'int', default: TransferCollectionStatus.INITIALIZED }, processedOnce: { type: 'bool', default: false }, isPaused: { type: 'bool', default: false }, retryCount: { type: 'int', default: 0 }, transfer: 'TransferModel', items: { type: 'linkingObjects', objectType: 'TransferCollectionItemModel', property: 'transferCollection' } } };
Version of Realm and Tooling
- Realm JS SDK Version: 5.0.3
- Node or React Native: Node (Electron)
- Client OS & Version: n/a
- Which debugger for React Native: n/a