Skip to content

Instantly share code, notes, and snippets.

@avinashlng1080
Created July 22, 2021 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avinashlng1080/b10446a8ccdffbbda92b59272590fe29 to your computer and use it in GitHub Desktop.
Save avinashlng1080/b10446a8ccdffbbda92b59272590fe29 to your computer and use it in GitHub Desktop.
Tutorials - Storage Layer

findAndObserve: Be aware that findAndObserve may throw an error if the ‘id’ it is looking for does not exist in the database. Always ensure that you are using this method in a safe way.

withObservables:

2nd level query or “A query in a query” export const withSystemIds = withObservables([], ({database}) => ({ currentChannelId: database.collections.get(SYSTEM).findAndObserve(SYSTEM_IDENTIFIERS.CURRENT_CHANNEL_ID), currentUserId: database.collections.get(SYSTEM).findAndObserve(SYSTEM_IDENTIFIERS.CURRENT_USER_ID), config: database.collections.get(SYSTEM).findAndObserve(SYSTEM_IDENTIFIERS.CONFIG), }));

const withChannelAndTheme = withObservables(['currentChannelId'], ({currentChannelId, currentUserId, database}: WithChannelAndThemeArgs) => ({ channel: database.collections.get(CHANNEL).findAndObserve(currentChannelId.value), user: database.collections.get(USER).findAndObserve(currentUserId.value), }));

In the above block code, you will that the value contained in currentChannelId is being used in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment