fire-entity
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -14,1 +14,2 @@ export interface EntitySystemProps { | ||
} | ||
export declare const EntityAttributes: string[]; |
@@ -0,1 +1,7 @@ | ||
export const EntityAttributes = [ | ||
'id', | ||
'type', | ||
'path', | ||
'parentPath' | ||
]; | ||
//# sourceMappingURL=entity.js.map |
@@ -0,2 +1,3 @@ | ||
export * from './entity'; | ||
export * from './store'; | ||
//# sourceMappingURL=index.js.map |
@@ -22,2 +22,3 @@ import * as firebase from 'firebase/app'; | ||
delete<T extends Entity>(entity: T): Promise<void>; | ||
update<T extends Entity>(entity: T): Promise<void>; | ||
} |
import * as tslib_1 from "tslib"; | ||
import 'firebase/firestore'; | ||
import { Subject } from 'rxjs'; | ||
import { EntityAttributes } from './entity'; | ||
import { convertFirestoreTimestamps } from './util'; | ||
@@ -32,4 +33,8 @@ function extractEntity(snap) { | ||
} | ||
function prepareDocumentInsert(data) { | ||
return Object.assign({}, data, { lastUpdated: new Date() }); | ||
function prepareDocumentData(data) { | ||
data = Object.assign({}, data, { lastUpdated: new Date() }); | ||
for (const attr of EntityAttributes) { | ||
delete data[attr]; | ||
} | ||
return data; | ||
} | ||
@@ -45,3 +50,3 @@ export class EntityStore { | ||
const collectionPath = getCollectionPath(insert); | ||
const preparedData = prepareDocumentInsert(data); | ||
const preparedData = prepareDocumentData(data); | ||
yield this.collection(collectionPath).add(preparedData); | ||
@@ -74,3 +79,8 @@ return undefined; | ||
} | ||
update(entity) { | ||
const path = entity.path; | ||
const data = prepareDocumentData(entity); | ||
return this.doc(path).update(data); | ||
} | ||
} | ||
//# sourceMappingURL=store.js.map |
{ | ||
"name": "fire-entity", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Allows for storing and retrieving documents in a standardized format from Firestore.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15897
297