share/sharedb

Projection's nested fields aren't being updated when subscribing to a query

Open

#365 geöffnet am 21. Apr. 2020

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (449 Forks)batch import
enhancementhelp wanted

Repository-Metriken

Stars
 (5.791 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 19h 56m) (5 gemergte PRs in 30 T)

Beschreibung

Created a projection as follows:

  backend.addProjection 'gameInfos', 'games',
    id: true
    testGame: true
    host: true
    classIds: true
    createdAt: true    
    mode: true
    'scenario.name': true
    'scenario.labels.publish': true
    'scenario.labels.unpublish': true
    'scenario.scenarioName': true
    'scenario.playedAt': true
    'scenario.gameCategory': true
    'scenario.gameType': true
    'scenario.password': true
    'scenario.roles': true

Subscribed to a regular query:

   $games = @model.query 'gameInfos', someQuery
   @model.subscribe $games, =>
       @model.ref '_page.games', $games
       @page.render ...

All first-level nested fields, e.g. mode, host are being reactively updated. But the specified nested fields, e.g. scenario.name are not. It will work fine if I pass just scenario: true into addProjection, i.e. all nested fields under scenario object will be updated reactively, but what if I only want a subset of the nested fields.

Contributor Guide