This library provides utility functions to connect to Mongo Realm Apps on MongoDB Atlas and query MongoDb Databases.
- a 'forRoot' method to initialize the Realm application when importing it in your application
- MongoRealmService provider with a set of methods to deal with Database connections & queries
1/ import the library into 'AppModule' :
import { MongoRealmModule } from '@ngx-pintado-mongo-realm;
2/ Call the 'forRoot' static method to load the Realm Config params and init the Realm App :
@NgModule({ imports: [ MongoRealmModule.forRoot({ id: '<realm-application-id>', timeout: <timeout en ms>, }) ] });
3/ Connect to a default Database :
await this.mongoRealmSrvc.setDefaultDb(<database_name>);
Use the utility functions in your components that uses the default Database :
this.docs = await this.mongoRealmSrvc.fetchCollection(<collection_name>);
4/ Or you can connect to another database than the one you defined as default :
const newDb = await this.mongoRealmSrvc.getDbConnection(<database_name>);
this.docs = await newDb.collection(<collection_name>).find();
Run ng generate component component-name --project ngx-pintado-mongo-realm
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module --project ngx-pintado-mongo-realm
.
Note: Don't forget to add
--project ngx-pintado-mongo-realm
or else it will be added to the default project in yourangular.json
file.
Run ng build ngx-pintado-mongo-realm
to build the project. The build artifacts will be stored in the dist/
directory.
After building your library with ng build ngx-pintado-mongo-realm
, go to the dist folder cd dist/ngx-pintado-mongo-realm
and run npm publish
.
Run ng test ngx-pintado-mongo-realm
to execute the unit tests via Karma.
To get more help on the Angular CLI use ng help
or go check out the Angular CLI Overview and Command Reference page.