googleapis / googleapis/google-cloud-node

[Firestore] `where` should use a "type safe" approach

Open
#7,456 1 comment 0 reactions 0 assignees View on GitHub
api: firestore library: nodejs-firestore priority: p2 type: feature request
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

You can currently use any string in the where clause of firestore. When using with converter the fieldPath should be "string safe"

Current implementation:

```ts
where(
fieldPath: string | FieldPath,
opStr: WhereFilterOp,
value: any
): Query;
```

Proposed implementation (when using with converter) :

```ts
where(
fieldPath: Path,
opStr: WhereFilterOp,
value: any
): Query;
```

where Path:

```ts
// Allows dot separated properties of
// for firebase updates
export type UpdatePath =
K extends string
? T[K] extends Record
? T[K] extends ArrayLike
? K | `${K}.${UpdatePath>}`
: K | `${K}.${UpdatePath}`
: K
: never;
export type Path = UpdatePath | keyof T;
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.