Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,27 @@ co(
);
```

## TypeScript write placeholders

`NodeFire` supports separate read and write type shapes. The optional second generic parameter
defines special write-value patterns, and defaults to none.

Each pattern is `[keyPattern, baseType, specialValue]`, where `specialValue` is allowed for keys
matching `keyPattern` when the field includes `baseType`.
All nested write properties also accept `null` to support Firebase delete semantics.

```ts
import NodeFire from 'nodefire';

type CounterIncrement = {'.sv': {increment: number}};
type WritePatterns = [
[`${string}timestamp`, number, {'.sv': string}],
[`${string}Count`, number, CounterIncrement]
];

const db = new NodeFire<FirebaseData, WritePatterns>(admin.database().ref());
```

## API

This is reproduced from the source code, which is authoritative.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nodefire",
"version": "4.0.0",
"version": "4.1.0",
"description": "A promise-centric Firebase library for NodeJS",
"main": "built/index.js",
"types": "built/index.d.ts",
Expand Down
Loading