Skip to content

Commit bfd54d7

Browse files
committed
[#12] implement forEach to iterate of query snapshot
1 parent 8f6e589 commit bfd54d7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/Web/Firestore/QuerySnapshot.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"use strict";
2+
3+
exports.forEachImpl = function (snapshot, callback) {
4+
return function () {
5+
return snapshot.forEach(function (documentSnapshot) {
6+
return callback(documentSnapshot)()
7+
})
8+
}
9+
}

src/Web/Firestore/QuerySnapshot.purs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
module Web.Firestore.QuerySnapshot where
22

3+
import Prelude
4+
import Data.Function.Uncurried (Fn2, runFn2)
5+
import Effect (Effect)
6+
37
foreign import data QuerySnapshot :: Type -> Type
8+
9+
foreign import data QueryDocumentSnapshot :: Type -> Type
10+
11+
foreign import forEachImpl :: forall a. Fn2 (QuerySnapshot a) (QueryDocumentSnapshot a -> Effect Unit) (Effect Unit)
12+
13+
forEach :: forall a. QuerySnapshot a -> (QueryDocumentSnapshot a -> Effect Unit) -> Effect Unit
14+
forEach = runFn2 forEachImpl

0 commit comments

Comments
 (0)