@travetto/model-firestore v4.0.7
Firestore Model Support
Firestore backing for the travetto model module.
Install: @travetto/model-firestore
npm install @travetto/model-firestore
# or
yarn add @travetto/model-firestore
This module provides an Firestore-based implementation of the Data Modeling Support. This source allows the Data Modeling Support module to read, write and query against Firestore.
Supported features:
- CRUD
- Indexed Out of the box, by installing the module, everything should be wired up by default.If you need to customize any aspect of the source or config, you can override and register it with the Dependency Injection module.
Code: Wiring up a custom Model Source
import { InjectableFactory } from '@travetto/di';
import { FirestoreModelConfig, FirestoreModelService } from '@travetto/model-firestore';
export class Init {
@InjectableFactory({
primary: true
})
static getModelSource(conf: FirestoreModelConfig) {
return new FirestoreModelService(conf);
}
}
where the FirestoreModelConfig is defined by:
Code: Structure of FirestoreModelConfig
import { RuntimeResources } from '@travetto/base';
import { Config } from '@travetto/config';
@Config('model.firestore')
export class FirestoreModelConfig {
databaseURL?: string;
credentialsFile?: string;
emulator?: string;
projectId: string;
namespace?: string;
autoCreate?: boolean;
credentials?: {
client_email: string;
project_id: string;
private_key: string;
};
async postConstruct(): Promise<void> {
if (this.emulator) {
process.env.FIRESTORE_EMULATOR_HOST = this.emulator;
}
if (this.credentialsFile && !this.credentials) {
this.credentials = JSON.parse(await RuntimeResources.read(this.credentialsFile));
}
}
}
Additionally, you can see that the class is registered with the @Config annotation, and so these values can be overridden using the standard Configuration resolution paths.
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
4 months ago
5 months ago
5 months ago
6 months ago
7 months ago
7 months ago
10 months ago
9 months ago
9 months ago
10 months ago
6 months ago
5 months ago
5 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
8 months ago
9 months ago
7 months ago
7 months ago
8 months ago
8 months ago
10 months ago
10 months ago
10 months ago
10 months ago
12 months ago
12 months ago
11 months ago
11 months ago
11 months ago
11 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago