MCPcopy Create free account
hub / github.com/firebase/quickstart-js / addMockRating

Function addMockRating

firestore/scripts/PopulateFirestore.js:148–161  ·  view source on GitHub ↗
(restaurantId, avgRating)

Source from the content-addressed store, hash-verified

146 * @param {number} avgRating: # of stars given to the restaurant
147 */
148const addMockRating = async (restaurantId, avgRating) => {
149 // Create new `rating` obj
150 const newRating = {
151 rating: avgRating,
152 text: data.ratingsTexts[avgRating],
153 userName: 'Anonymous (Bot)',
154 };
155
156 // Add new rating to given restaurant's `ratings/` subcollection
157 await addDoc(
158 collection(db, `restaurants/${restaurantId}/ratings`),
159 newRating
160 );
161};
162
163const main = async () => {
164 // Connect to emulators if a `demo` environment is pulled

Callers 1

addFakeRestaurantFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected