Add plugin
This commit is contained in:
27
plugins/user.js
Normal file
27
plugins/user.js
Normal file
@@ -0,0 +1,27 @@
|
||||
export class User {
|
||||
constructor (gamesStarted) {
|
||||
this.gamesStarted = []
|
||||
|
||||
gamesStarted.forEach(e => {
|
||||
this.gamesStarted.push({ course: e.kurs, game: e.spiel })
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Firestore data converter
|
||||
export const UserConverter = {
|
||||
toFirestore: (user) => {
|
||||
const spieleBegonnen = []
|
||||
user.gamesStarted.forEach(e => {
|
||||
spieleBegonnen.push({ kurs: e.course, spiel: e.game })
|
||||
})
|
||||
|
||||
return {
|
||||
spieleBegonnen
|
||||
}
|
||||
},
|
||||
fromFirestore: (snapshot, options) => {
|
||||
const data = snapshot.data(options)
|
||||
return new User(data.spieleBegonnen)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user