Your app now has automatic data expiration after 7 days with manual cleanup.
- Admin Adds Price → Saves with
expiresAt= today + 7 days - App Shows Data → Filters out expired data automatically (users never see old data)
- Admin Clicks Cleanup → Permanently deletes expired data from Firebase
expiresAt: sevenDaysFromNow // 7 days from now// Only show non-expired data
if (!expiresAt || expiresAt > now) {
pricesData.push(item);
}Location: Admin Panel → Quick Actions → "Clean Up Old Data"
What it does:
- Compares
expiresAtwith current date - Deletes all expired entries from Firebase
- Shows count of deleted entries
- Add prices normally → They automatically get 7-day expiration
- Check dashboard → See all current prices
- Click "Clean Up Old Data" when you want to delete expired entries
- Confirm deletion → Permanently removes old data from Firebase
- See only fresh data (less than 7 days old)
- Never see expired prices (automatically filtered)
- No action needed (works automatically)
- Admin adds: Ramanagara CB price
- Firebase saves:
expiresAt= Day 7 - User sees: ✅ Price visible
- User sees: ✅ Price visible
- No action needed
- User sees: ❌ Price hidden (expired)
- Firebase still has data (not deleted yet)
- Admin clicks "Clean Up Old Data"
- Firebase: ✅ Data permanently deleted
- Storage freed up
- Open admin panel
- Add new price (any market/breed)
- Check Firebase → should have
expiresAtfield - Check app → price should appear
- Go to Firebase Console
- Find any document in
cocoonPrices - Change
expiresAtto yesterday's date - Refresh app → that price should disappear ✅
- Make some test data expired (change dates in Firebase)
- Go to Admin Dashboard
- Click "Clean Up Old Data"
- Should show: "Successfully deleted X expired entries"
- Check Firebase → expired data should be gone ✅
✅ 100% FREE - No Cloud Functions, no paid Firebase plan ✅ Automatic Filtering - Users never see expired data ✅ Manual Control - Admin decides when to delete from Firebase ✅ Simple - No complex setup, no indexes needed ✅ Safe - Confirmation dialog before deletion
| Feature | Manual Cleanup (Current) | Cloud Functions |
|---|---|---|
| Cost | FREE ✅ | Requires Blaze Plan ($) |
| Setup | Done ✅ | Requires deployment |
| Control | Admin decides when | Automatic |
| Firebase Storage | Data removed on cleanup | Auto-removed |
| User Experience | Same (filtering works) | Same |
Before Cleanup:
- Expired data exists but hidden from users
- Takes up Firebase storage quota
After Cleanup:
- Expired data permanently deleted
- Storage quota freed up
Recommendation:
- Run cleanup weekly or monthly
- Or when you see "No Expired Data" message stops appearing
Solution:
- Check if document has
expiresAtfield in Firebase - Old documents (before update) might not have this field
- Admin can edit old prices to add expiration
Solution:
- This is good! No expired data to clean up
- Try again after more time passes
Solution:
- Check admin is logged in
- Check Firebase permissions
- Check console for errors
-
expiresAtfield added when saving prices - HomeScreen filters expired data
- Cleanup button added to admin dashboard
- Cleanup function deletes expired data
- Test with real data
- Build production APK with
google-services.json - Distribute APK to users
npm start- Add test prices
- Change dates in Firebase to test expiration
- Click cleanup button
eas build --platform android --profile production- Download APK from Expo
- Share with users
- Enjoy automatic expiration + manual cleanup!
What You Have:
- ✅ Data expires after 7 days (hidden from users)
- ✅ Admin cleanup button (permanent deletion)
- ✅ Completely FREE solution
- ✅ Simple and effective
No Need For:
- ❌ Cloud Functions
- ❌ Complex Firestore indexes
- ❌ Paid Firebase plan
- ❌ Scheduled jobs
Perfect balance of automation and control! 🎉