firebase / firebase/firebase-js-sdk
[Feature request] Query toJson, fromJson
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 37
Description
### Operating System
macOS
### Browser Version
Safari 16.5.2
### Firebase SDK Version
10.4.0
### Firebase SDK Product:
Firestore
### Describe your project's tooling
index.html with source tag. Just javascript.
### Describe the problem
It's a feature request. I'd like the ability to be able to serialize and deserialize a Query. There are classes on the Auth package that have a fromJson and toJson methods, for example. I'd like to be able to reconstruct a Query from a string.
I also created a [discussion](https://github.com/firebase/firebase-js-sdk/discussions/7690) for alternative solutions in the meantime (if this ever gets implemented).
### Steps and code to reproduce issue
Given that I have any query, for example
```
import { collection, query, where } from "firebase/firestore";
const citiesRef = collection(db, "cities");
// Create a query against the collection.
const q = query(citiesRef, where("state", "==", "CA"));
```
I'd like to be able to do something like
```
const serialized = JSON.stringify(q);
const q2 = Query.fromJson(JSON.parse(serialized));//query from json
```
Contributor guide
Assessment
This issue has not been assessed yet.