All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning. This change log follows the format documented in Keep a CHANGELOG.
- Added
as
method to collections and collections groups. The method allows sharing functionality between collections and collections groups. Read the sharing functionality guide.
- Deprecated
Typesaurus.Collection
,Typesaurus.Ref
, andTypesaurus.Doc
in favor ofTypesaurus.SharedCollection
,Typesaurus.SharedRef
, andTypesaurus.SharedDoc
to reflect the new sharing functionality. Read the sharing functionality guide.
This release has no user-facing changes, it's a dev release powering the Typesaurus Point-in-Time Recovery adapter.
- Fixed the native Firebase reference/query object not being exposed.
- Renamed
native
tonativeSymol
in the adapters.
- Added ability to access the database instance from subscription promisesa via
dbSymbol
symbol.
This release has no user-facing changes, it's a dev release powering the Typesaurus Point-in-Time Recovery adapter.
- Added native Firestore reference/query object to the subscription promise object, which is accessible via
native
symbol to enable low-level access for advanced use cases, like Typesaurus Point-in-Time Recovery adapter. Don't use it!
This release has no user-facing changes, it's a dev release powering the Typesaurus Point-in-Time Recovery adapter.
- Export admin & web adapters to enable low-level access for advanced use cases, like Typesaurus Point-in-Time Recovery adapter. Don't use those!
-
Fixed
Typesaurus.Ref
being incompatible with theRef
type inferred from the actual database API. -
Fixed
update
widening the model type when passing an object. It was allowed to pass an object with extra fields. It is now fixed except for data returned from the function argument, which is still prone to the problem, which is a TypeScript limitation.
- Added type-safe way to share functionality between refs and docs. Read the sharing functionality guide. Read the architecture desicion record (ADR-2).
- Fixed
batch
not using respecting collections renaming.
- Made the
Name
generic inTypesaurus.Collection
andTypesaurus.Ref
types optional.
- Added
sum
andaverage
aggregation methods to collections, queries and collection groups.
- Fixed subcollections path for renamed with
.name
collections.
Completely revamped Typesaurus with a new API and new features. Follow this guide to learn how it works.
- Replace deprecated
@firebase/rules-testing
with@firebase/rules-unit-testing
.
- Third argument in
doc
(meta
) now optional.
-
BREAKING: Transaction write functions now synchronous and don't return promises.
-
Added
meta
to doc, which presents only in the web environment.
- Added
docId
constant-helper that allows to sort or filter by the document ID.
- Added collection group support to
all
andonAll
.
-
BREAKING: When using with ESM-enabled bundler, you should transpile
node_modules
. TypeScript preserves many modern languages features when it compiles to ESM code. So if you have to support older browsers, use Babel to process the dependencies code. -
BREAKING:
add
now returnRef
instead ofDoc
to avoid confusion that the returned data match the current database state which might be not a case when using with field values i.e.value('serverDate')
. -
BREAKING:
set
,transaction.set
andbatch.set
now returnPromise<void>
(orvoid
in case ofbatch.set
). The same reasoning as for theadd
(see above). -
BREAKING:
set
,transaction.set
andbatch.set
now don't acceptmerge
option. Instead use the newupset
function that provides better typing and ensures data consistency. -
BREAKING:
value('serverDate')
now returns a simple object instead of monkey-patchedDate
instance. -
BREAKING:
ModelUpdate
renamed toUpdateModel
for consitency withSetModel
andUpsetModel
. -
BREAKING:
ref
now don't generate id if the second argument is omitted, useid
function to generate new id instead. -
update
now allows passing partial data into nested fields. Previously only root fields were optional. -
Now the browser adaptor imports
firebase/app
andfirebase/firestore
on-demand (using ESM'simport()
) rather than in the root level of the library. That dramatically improves initial paint time and helps with bundle caching. Now every time you make a small change in the app, the user won't have to downloadfirestore
modules as well.
-
Added ESM version of the code that enables tree-shaking.
-
Added new
upset
,batch.set
andtransaction.set
functions that sets or updates the value of given document. It replacesmerge
option available in the previous version of Typesaurus. -
Added new
id
function that generates random id for a document.
- Added
onGetMany
function.
- Added testing module
typesaurus/testing
withinjectTestingAdaptor
andsetApp
that allow to use Typesaurus with@w
.
- Added ability to use docs in cursors (
startAt
,startAfter
, etc.). #28
-
BREAKING: Rework the
subcollection
function to support nested subcollections. #18 -
BREAKING: Rework the
transaction
function. Now it accepts two functions as arguments. The first function allows only reading, and another allows only writing. It will make it impossible to perform reads after writes, which would throw an exception as it's a Firebase limitation. #16 -
Define the
transaction
function result type. #16 -
Remove
@google-cloud/firestore
,firebase
, andfirebase-admin
from the peer dependencies to get rid of unavoidable warnings when Typesaurus is used only in the web or Node.js environment. #17
- Add
Batch
type that defines the object returned from thebatch
function.
- Make
serverDate
value to actually call Firebase'sserverTimestamp
instead of passing current date.
- Fix
array-contains
filter support inwhere
.
-
BREAKING:
untypedWhereArrayContains
was removed in favor of native support ofarray-contains
filter inwhere
. -
BREAKING: Update Firebase dependencies to the latest versions:
@google-cloud/firestore
:>=2.6.0
firebase
:>=7.5.0
firebase-admin
:>=8.8.0
- Added
in
andarray-contains-any
filters support towhere
. Read more about these filters in the Firebase announcement.
-
BREAKING: Remove deprecated
clear
that was renamed toremove
. -
BREAKING: Return
null
instead ofundefined
when a document isn't found.
- Loose up peer dependency requirements. See #5 for the reasoning.
- Add
getMany
function. Kudos to @thomastoye!
- BREAKING: Move Firebase packages to the peer dependencies to prevent npm from installing two or more firebase-admin versions which cause obscure errors like "The default Firebase app does not exist".
- Now
ref
generates an id when one isn't passed.
- Rename
clear
toremove
everywhere keepingclear
as an alias which will be removed in the next major version.
-
Export
field
from the package root -
Added support for
value
(i.e.value('increment', 1)
) in the field paths. -
Add support for merge set that use the current document values as defaults:
await set(user.ref, { name: "Sasha", date: new Date(1987, 1, 11) }); await set(user.ref, { name: "Sasha" }, { merge: true }); await get(user.ref); //=> { data: { name: 'Sasha', date: new Date(1987, 1, 11) }, ... }
First public release.