- Update dependencies to
firebase-admin
>= 11.0.0
- Fix handling null params on
useCollectionCount
,useCollectionGroupCount
.
- Updated firebase peerDependencies to >=9.11.0 to enable the use of 10.x
- Fixed an issue
id
inwhere
andorderBy
was not converted todocumentId
. This issue was introduced in version 2.0.3 and caused the feature to not work as intended.
- Modify type
QueryParams
to allowid
inwhere
,orderBy
.
- Add
limitToLast
params.
- Fix peerDependencies for firebase-admin.
- Add count property to SWR key for counting functions.
This means that the SWR key has changed for the
useCollectionCount
anduseCollectionGroupCount
functions.
- Add support CollectionGroup on
useGetDocs
. AddisCollectionGroup
parameter. - Add server module. This may be useful for SSG and SSR. You can import from
@tatsuokaniwa/swr-firestore/server
.
import { useCollection, useGetDocs } from "@tatsuokaniwa/swr-firestore"
import { getCollection } from "@tatsuokaniwa/swr-firestore/server"
export async function getStaticProps() {
const params = {
path: "posts",
where: [["status", "==", "published"]],
}
const { key, data } = await getCollection<Post>({
...params,
isSubscription: true, // Add the prefix `$sub$` to the SWR key
})
const { key: useGetDocsKey, data: useGetDocsData } = await getCollection<Post>(params)
return {
props: {
fallback: {
[key]: data,
[useGetDocsKey]: useGetDocsData,
}
}
}
}
export default function Page({ fallback }) {
const { data } = useCollection<Post>({
path: "posts",
where: [["status", "==", "published"]],
})
const { data: useGetDocsData } = useGetDocs<Post>({
path: "posts",
where: [["status", "==", "published"]],
})
return (
<SWRConfig value={{ fallback }}>
{data?.map((x, i) => <div key={i}>{x.content}}</div>)}
</SWRConfig>
)
}
- Update
useCollection
,useCollectionCount
,useCollectionGroup
,useCollectionGroupCount
, anduseGetDocs
hooks to include query cursor parameters:startAt
,startAfter
,endAt
, andendBefore
- Add
orderBy
parameter touseCollectionCount
anduseCollectionGroupCount
hooks to support query cursor - Remove duplicate code for SWR key tweaking
Same code as the previous version 1.1.1
.
We had to release this version because the README.md file was not included when the package was published on npmjs.com.
- Add Middleware to adjust the key for SWR
- Add
swrOptions
parameter to the Subscription.
- Allow raw QueryConstraints
- Modify Error Type to
FirestoreError
- Modify tests
- Fix
where
param's type
- Replace lodash dependency to lodash-es
- Refactored type to support nested objects
- Upgraded firebase dependency from
^9.17.1
to^9.11.0 < 10.0.0
to enable availability of thegetCountFromServer
function - Minor code refactoring, formatting
- Modify vite.config.ts to set SWR as an external dependency
- Add
useGetDocs
function - Add
useGetDoc
function
- Initial release