I have a database with documents like below:
Event
0e354b76-aa36-4af1-aa38-ef22423c9968
candy: 20
date: "2019-04-22T17:00:30.234Z"
id: "0e354b76-aa36-4af1-aa38-ef22423c9968"
packages: []
timestamp: 1555952430
title: "Test edit"
userId: "123"
1572a408-9be5-4d00-9584-69492ddbccc1
candy: 400
date: "2019-05-02T03:04:05Z"
id: "1572a408-9be5-4d00-9584-69492ddbccc1"
packages: []
timestamp: 1556766245
title: "Another test"
userId: "123"
I'd like to query for events that are in the future and have the userID 123. I'm using this golang FireBase library and I've figured out how to do each of these things individually:
ref := fbDB.NewRef("/Event")
// user id
ref.OrderByChild("user").EqualTo(uid).Get(c, &events);
// future events
ref.OrderByChild("timestamp").StartAt(time.Now().Unix()).LimitToFirst(numberToRetrieve).Get(c, &events);
but I can't figure out how to combine the two. How would I go about combining these two filters?
Updated structure
Event
by_user
123
0e354b76-aa36-4af1-aa38-ef22423c9968
candy: 20
date: "2019-04-22T17:00:30.234Z"
id: "0e354b76-aa36-4af1-aa38-ef22423c9968"
packages: []
timestamp: 1555952430
title: "Test edit"
userId: "123"
0e354b76-aa36-4af1-aa38-ef22423c9968
...