Flutter - Firebase - Truy vấn theo giá trị mục danh sách [trùng lặp]

Dec 31 2020

Tôi có một danh sách khả dụng và muốn truy vấn dựa trên giá trị, ví dụ: khóa 31, là> 0. Tôi chưa tìm thấy cú pháp chính xác để biến nó thành hiện thực. tôi nhận được

flutter: Paths must not contain '~', '*', '/', '[', or ']'.

Có cách nào để làm việc này không? Hay tôi cần phải suy nghĩ lại về truy vấn?

final Query nextSlot = FirebaseFirestore.instance
        .collection('locations')
        .where('availability{31}', isGreaterThan: 0);

..does not give error but gives 0 results..

        .where('availability[31]', isGreaterThan: 0);
        .where('availability/31', isGreaterThan: 0);
.. returns the format error.

Chúc mừng năm mới và cảm ơn!

Trả lời

1 jaredbaszler Dec 31 2020 at 03:41

Tôi khá chắc chắn rằng firebase và Dart sử dụng ký hiệu dấu chấm, vì vậy bạn cần điều này:

final Query nextSlot = FirebaseFirestore.instance
        .collection('locations')
        .where('availability.31', isGreaterThan: 0);