Skip to content

Instantly share code, notes, and snippets.

View gregfenton's full-sized avatar

Greg Fenton gregfenton

View GitHub Profile
@gregfenton
gregfenton / cleanup_firestore.js
Last active September 10, 2023 02:18
Deletes all records from a Firestore collection that match some criteria -- command-line JavaScript/node
/**
* cleanup_firestore.js
*
* This code is a "node script" used to delete all documents from a Firestore
* collection that are older than a given date. This script can run against
* "the cloud" or the emulator.
*
* The jump point for the script is this line in main():
*
* await deleteDocs('orders', 'closedDate', '<', new Date('2021/08/31'))
@gregfenton
gregfenton / useVehicleList.js
Created June 8, 2020 00:02
a custom hook for "paging" queries to Firestore
import { useEffect, useState } from "react";
import { useSelector } from "react-redux";
export const FIRESTORE_META_ID = "__META_ID__";
/**
* A custom hook to query the "vehicles" top collection of a Firestore database.
*
* @param {Firestore} firestore - instance of firestore, such as you get in props when a parent component is wrapped in `withFirestore()`
* @param {number} pageNum - the current page number to fetch; first page is 0, second page is 1, etc...
@gregfenton
gregfenton / Location Selector
Last active May 2, 2020 20:46 — forked from hanuz06/Location Selector
Location Selector
import React, { useState, useEffect } from "react";
import {
StyleSheet,
Text,
View,
ActivityIndicator,
Alert,
Button,
} from "react-native";
import * as Location from "expo-location";