Open JaydenBea opened 6 months ago
12:00pm (start)
The first thing the class needs is Future
variables for the various Stream
s and lists needed by different pages. Of note:
FeederPage
)Something I need to find is whether lists of QueryDocumentSnapshot
s (the latter three) will dynamically update like Streams do. It would be important for the Admin page in particular that the lists update after stations/cats are added/removed.
12:25pm (since 12pm)
There is a distinct difference between getting the results of, say, a query that returns a Future with a list of QueryDocumentSnapshots (FirebaseHelper().usersRef.get()
) and a Stream (FirebaseHelper.usersRef.snapshots()
). Both are asynchronous operations that takes some time to complete. However, where a Future
does the operation once and returns an unchanging value, a Stream
's values can update over time. Where a Future
will return a list of users as they were at the time of Query completion, a Stream
will react to changes in the database after data is originally fetched.
For now, I'm going to add variables for both Stream
and Future
versions of each collection.
1pm (Since 12:25pm)
Added Streams and Futures for all four collections, including initializing functions for the three. The initializers use a common function with a generic typing. The list of stations is sorted by ID.
Working on adding getters that, when given a DocumentReference
, returns the DocumentSnapshot
of the document referenced by the snapshot. I'm also trying to give this dynamic typing for redundancy's sake.
1:30pm (since 1pm)
Added a generic getter as described above. This was done by introducing Model
, an abstract class that the other models (UserDoc, Entry, Station, Cat) all extend. The abstract class itself has no methods. It could include toJson
, but not fromJson
, as the latter is a constructor.
2pm (since 1:30pm)
Added functions from FeederDataSource
and confirmed the functionality of the items in Snapshots
.
8:20pm (start)
Snapshots
' variables and methods static
, as I believe this makes more sense (there's a single point of data access, not multiple).FeederDataSource
within the feeder files to references to Snapshots
Snapshots
so that all data access within different feeder files is done through that class.8:50pm (since 8:20pm)
FeederDataSource
with references to Snapshots
.Snapshots.getDocument
where the generic type wasn't checked correctly.
T.runtimeType
' when that wasn't necessary (should've just been T
)typeName _
in place of typeName
in switch case, but this caused a bug9:08pm (since 8:50pm)
equalizeTime
to Snapshots
, from FirebaseHelper
runTransaction
method to Snapshots
, which runs FirebaseFirestore.runTransaction
.FirebaseHelper
in all Feeder Files with to references to Snapshots
.
An class that simplifies access to information needed in the database is quite desirable. It abstracts database access, allowing changes to be done without requiring mass rewrites, and will make things overall easier.
The
FirebaseHelper
class initializes elements needed for access, including all collection references, but I'm going to make another class between this one and classes responsible for presenting UI to the user. TheSnapshots
class will contain methods and variables that are needed by various components of the database, and simplify their use.