Last active
February 6, 2019 16:05
-
-
Save wovalle/4a7f37999cb8fb82dd43fc9e076c7fd9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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