Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/s-soltys/angular2-minimongo

The minimongo library for Angular 2+
https://github.com/s-soltys/angular2-minimongo

Last synced: about 1 month ago
JSON representation

The minimongo library for Angular 2+

Awesome Lists containing this project

README

        

# angular2-minimongo
[![Build Status](https://travis-ci.org/s-soltys/angular2-minimongo.svg?branch=master)](https://travis-ci.org/s-soltys/angular2-minimongo)

Use minimongo in your Angular 2 app.
This package exposes the [minimongo](https://github.com/mWater/minimongo) library as an Angular2 module with providers.

# How to install:
```
$ npm install --save angular2-minimongo
```

# How to use:
### Import the Minimongo module in your bootstrap module:
```typescript
import { MinimongoModule } from 'angular2-minimongo';

@NgModule({
imports: [
MinimongoModule.forRoot({ namespace: '#your-database-namespace' }),
]
})
export class AppModule { }
```

### Import and use the Minimongo service:
```typescript
import { MinimongoService } from 'angular2-minimongo';

@Injectable()
export class TaskService {
tasksCollection = this.minimongo.getCollection('tasks');

constructor(private minimongo: MinimongoService) {

}
}
```

### Usage: the collection interface
```typescript
/*
Types are the best documentation.
Collections provided by the Minimongo service implement the ObservableCollection interface.
Parameters named selector and docs are standard mongo selectors.
*/
export interface ObservableCollection {
findOne(id: string): Observable;
findOne(selector: any, options?: any): Observable;
find(selector?: any, options?: any): Observable;
upsert(doc: T): Observable;
upsert(docs: T[]): Observable;
remove(id: string): Observable;
}
```

# How to build and test:
Project is based on the angular-cli.
To run tests on this package just run:
```
ng test
```

# Roadmap:
- Implement additional and more robust collection methods