Created
November 18, 2018 02:23
-
-
Save rajatk16/d4e96db57df574c7489d0b14da861d2a to your computer and use it in GitHub Desktop.
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
<script> | |
import firebase from 'firebase' | |
import { db } from '../main' | |
export default { | |
name: 'Comics', | |
data () { | |
return { | |
comics: [], | |
name: '', | |
image: '' | |
} | |
}, | |
firestore () { | |
return { | |
comics: db.collection('comics').orderBy('createdAt') | |
} | |
}, | |
methods: { | |
addComic (name, image) { | |
const createdAt = new Date() | |
db.collection('comics').add({ name, image, createdAt }) | |
// Clear values | |
this.name = '' | |
this.image = '' | |
}, | |
deleteComic (id) { | |
db.collection('comics').doc(id).delete() | |
}, | |
logout () { | |
firebase.auth().signOut().then(() => { | |
this.$router.replace('login') | |
}) | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment