We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Querying recurring events in firebase on a given date

Hi,

I have read the documentation on recurring events on SFCalendar, and I understand that the recurring frequency is a string attribute on 1 given appointment/event. e.g. if 1 appointment recurs 30 next days, it is represented on a data level as 1 appointment with the recurrence being an attribute describing 30 days.

Now, we are working on an application, that creates an availability appointment (i.e. "available times")  over a given timeframe for users. What we would like to know, is in Firebase, NOT the calendar, how may we query whether or not this user has a given date x, as available (i.e, query firebase, without downloading all appointments, to find out if date x, is available, taken or not?).

I hope my question is clear. Look forward to your response.



3 Replies

MS Muniappan Subramanian Syncfusion Team November 17, 2022 01:04 PM UTC

Based on the shared details, we have checked your requirement. In the Firestore database, the appointment recurrence rule is added in the format of a string. The recurrences of the appointment did not store in the fire store database which means the parent appointment details alone can get in the database. You can write the query to get the appointment from the Firestore database. Here we have loaded the appointment to the calendar based on the end-time comparison (IsLessThan). Refer to the below code snippets,


Future<void> getDataFromFireStore() async

{

    var snapShotsValue = await databaseReference

        .collection("CalendarEventsCollection")

        .where('EndTime', isLessThan: Timestamp.fromDate(DateTime(2022, 11, 17, 12, 0, 0)))

        .get();

    List<Meeting> list = snapShotsValue.docs

        .map((e) => Meeting(

            eventName: e.data()['Subject'],

            from: formatTimestamp(e.data()['StartTime']),

            to: formatTimestamp(e.data()['EndTime']),

            RRule: e.data()['RecurrenceRule'],

            background: Colors.blue,

            isAllDay: false))

        .toList();

    events = MeetingDataSource(list);

}


Find the database structure in the Firestore database.




We have prepared a simple sample for the same, please find the attached sample.


Attachment: flutterfirebasecalendar_de175454.zip


MA Marsh November 17, 2022 02:11 PM UTC

Thanks Muniappan.

If I understand your example correctly, here you are querying the parent appointment, not a recurring instance. e.g. Your appointment is on Nov 17 2022, and your query is against the parent. However that same parent has a recurrence of everyday for the next 15 days (i.e. Nov 17 '22- Dec 2 '22). My question is, how can I query if there is an appointment ON Nov 21 2022. For which there is no "parent" appointment on that given day?

Thanks.




MS Muniappan Subramanian Syncfusion Team November 18, 2022 12:42 PM UTC

# Regarding how I can query if there is an appointment ON Nov 21 2022

As we mentioned in the previous update, we have added the recurrence appointment on November 17, 2022. This appointment will recur for the next 15 days. In the Firestore database, the parent appointment alone is stored, and the recurrences of the next 15 days will not be stored. In the parent appointment, the recurrence rule is added in string format. So, you cannot able to write a query to get the appointment details on the recurring date (November 21, 2022).  For your reference, we have handled the query on the parent appointment in that sample.




Loader.
Live Chat Icon For mobile
Up arrow icon