Services are not included in realm-web code if it's installed via npm

Hi again,

I’ve noticed that realmapp.services is undefined (it’s missing from the App constructor) if u install the package via npm (1.0.0-rc.1).

It works if you use this script https://unpkg.com/realm-web@0.9.0/dist/bundle.iife.js cause services are present here.

Is it intended? This way you can’t access MongoDB service if you install via npm install.

This is intended. There’s a breaking change in Realm Web 1.0.0-rc.1 altering the API to align with the Realm JS API where services and functions are available from the User instance:

const mongo = user.mongoClient("<atlas service name>");
const db = mongo.db("<my-database-name>");
const collection = db.collection("<my-collection-name>");

See https://docs.mongodb.com/realm-sdks/js/latest/Realm.User.html#mongoClient

2 Likes

My bad, I’m sorry :smile:

No worries :slight_smile: As Realm Web approaches 1.0.0 I don’t expect breaking changes like this in the near future.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.