Slide 14
Slide 14 text
Firestore-simpleで書いた場合
type User = {
// id
は必須プロパティ
id: string, name: string, age: number,
createdAt: Date,
}
type UserFirestore = {
name: string, age: number,
created_at: Date,
}
const firestoreSimple = new FirestoreSimple(firestore)
const userCollection = firestoreSimple.collection({
path: 'users',
decode: (doc) => {
return {
id: doc.id,
name: doc.name,
age: doc.age,
createdAt: doc.created_at.toDate()
}
}
})
const user = await userCollection.fetch('alice')
// => { id: 'alice', name: 'alice',
// => age: 20, createdAt: 2020-06-20T13:12:54.816Z }
14