1

I have an ambitious goal to build a cross platform app that would share as much code as possible that would run on desktop, mobile devices and web browsers. The application is going to use realm database with mongoDB atlas for cloud sync.

All of those nice offline-first, automatic sync capabilities are available for desktop and mobile devices. I wonder if I’d be able to use the same for blazor web assembly?

Let’s say it’s not possible, what alternative could I use as database? And what could I do to implement real time sync with mongoDB realm cloud database on blazor as a fallback?

kyurkchyan
  • 2,260
  • 2
  • 23
  • 37
  • They support Angular and the like, so a wrapper should be possible. But Google shows no matches, you'll probably have to start one yourself. – H H Nov 14 '20 at 21:02

1 Answers1

2

Neither the Realm Database, nor Realm Sync can run in the browser at the moment. The team has plans to explore Wasm as a potential target, but there's no definitive timeline for that yet.

In terms of workarounds, you could use GraphQL or the Web SDK both of which expose an API to query MongoDB via an HTTP API. One edge the Web SDK has over GraphQL is that it supports watching a collection for changes, whereas GraphQL only has Query and Mutation support. With both of these solutions, you'll need to design your own caching/storage layer.

Nikola Irinchev
  • 1,911
  • 1
  • 13
  • 17
  • Nikola thanks a lot for the answer, all does make sense. Web SDK is javascript/typescript based. Is there another SDK that's consumable by .NET and is able to do CRUD and monitor for changes? Or I will have to create a bridge within blazor to access js sdks? – kyurkchyan Nov 17 '20 at 09:40
  • Unfortunately, I don't think there's one at this point, so bridging the JS SDK seems like your best bet. – Nikola Irinchev Nov 17 '20 at 14:19
  • Got you. This may be a different thing, I came across this page. It seems there is C# SDK to monitor collection changes, not sure if it's intended to use in every place where .net works or has limitations on target platforms https://docs.mongodb.com/manual/changeStreams/ – kyurkchyan Nov 17 '20 at 14:38
  • These docs are for the C# driver - that one's different from the Realm SDK. Technically, you can use the C# driver, unfortunately, only a subset of the wire protocol functionality is exposed on MongoDB Realm: https://docs.mongodb.com/realm/mongodb/connect-over-the-wire-protocol/ and change streams is not part of that list. So while I haven't tested it personally, I don't believe it will work for your use case. – Nikola Irinchev Nov 23 '20 at 14:47
  • Make sense Nikola! Thanks again for clarifications. – kyurkchyan Nov 23 '20 at 14:48