This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
EMULATOR="cloud-firestore-emulator" | |
EMULATOR_TARGET=$(find ~/.cache/firebase/emulators/ -type f -name "$EMULATOR*.jar" | sort -r | head -n1) | |
if [ -z "$EMULATOR_TARGET" ]; then | |
echo "Could not find the firestore emulator. Ending test run." | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"emulators": { | |
"firestore": { | |
"host": "127.0.0.1" | |
}, | |
"functions": { | |
"host": "127.0.0.1" | |
} | |
}, | |
"firestore": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service cloud.firestore { | |
match /databases/{database}/documents { | |
// GENERIC // | |
function hasRoleForResource(targetResource, targetRoles) { | |
return targetResource.data.role in targetRoles; | |
} | |
// USERS // |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as admin from 'firebase-admin'; | |
let cachedAdmin: admin.app.App; | |
export function init(overrideApp?: admin.app.App) { | |
if (cachedAdmin) { | |
return; | |
} | |
cachedAdmin = overrideApp || admin.initializeApp(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { firestore } from 'firebase-functions'; | |
import { FieldValue, getFirestore } from '../admin'; | |
/** | |
* When a new homestead is created we want to automatically set the owner access document for that homestead. | |
* Additionally, we want to set the reverse relationship on the user document. | |
*/ | |
export const updateMembershipOnHomesteadCreation = firestore | |
.document('homesteads/{homesteadId}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as uuid from 'uuid/v4'; | |
type Collections = | |
| 'catchAlls' | |
| 'homesteads' | |
| 'users'; | |
export enum COLLECTIONS { | |
CATCH_ALL = 'catchAlls', | |
HOMESTEADS = 'homesteads', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as firebase from '@firebase/testing'; | |
export type Firestore = firebase.firestore.Firestore; | |
export type DocumentReference = firebase.firestore.DocumentReference; | |
let testIncrement = 0; | |
let useRealProjectId = false; | |
const projectIdBase = `firestore-emulator-${Date.now()}`; | |
function adjustTestIncrement() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:cloud_firestore/cloud_firestore.dart'; | |
import 'package:flutter_bloc/flutter_bloc.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:grow_smart/blocs/homestead/bloc.dart'; | |
import 'package:grow_smart/services/service_locator.dart'; | |
class ListPlantVarieties extends StatelessWidget { | |
@override | |
build(context) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { firestore } from 'firebase-functions'; | |
import { getFirestore } from '../admin'; | |
import { IndexMeta } from '../types'; | |
/** | |
* When a new homestead is created we want to create | |
* the needed indices so they can be immediately accessed. | |
*/ | |
export const createIndicesForHomestead = firestore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { firestore } from 'firebase-functions'; | |
// @ts-ignore there is no declaration file for this module | |
import * as sizeOf from 'firestore-size'; | |
import { getFirestore } from '../admin'; | |
import { IndexMeta } from '../types'; | |
// 1 MiB * 1024 kB * 1024 B * margin of error | |
const MAX_DOCUMENT_SIZE = 1 * 1024 * 1024 * 0.95; |
OlderNewer