Skip to content

Instantly share code, notes, and snippets.

@wovalle
Last active February 6, 2019 16:05
Show Gist options
  • Save wovalle/4a7f37999cb8fb82dd43fc9e076c7fd9 to your computer and use it in GitHub Desktop.
Save wovalle/4a7f37999cb8fb82dd43fc9e076c7fd9 to your computer and use it in GitHub Desktop.
import Band from './models/Band'
import { getRepository } from 'fireorm'
const bandRepository = getRepository(Band, firestore);
// Create a band
const band = new Band();
band.name = "A Perfect Circle";
band.formationYear = 1999;
band.genres = ['alternative-rock', 'hard-rock']
const bandDocument = await bandRepository.create(band);
console.log(`Created band with id: ${band.id}`);
// Read a band
const aPerfectCircle = await bandRepository.findById('a-perfect-circle');
// Update a band
bandDocument.genres = ['alternative-rock', 'hard-rock', 'art-rock'];
await bandRepository.update(bandDocument);
// Delete a band
await bandRepository.delete('a-perfect-circle');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment