Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
739 views
in Technique[技术] by (71.8m points)

firebase - Error Deploying Firestore Function with a space in the name of a collection

I'm trying to deploy a cloud function that updates an Algolia Search index whenever a new document is created in my Firestore. Everything seems to start well but then at the very end, it errors out. I've been through the docs and it feels like my syntax is correct so I'm not sure what to do at this point. The Cloud Functions log don't point to anything and just echo the error that I received below

Error Message:

=== Deploying to 'test-ffdbb'...

i  deploying functions
i  functions: ensuring necessary APIs are enabled...
i  runtimeconfig: ensuring necessary APIs are enabled...
+  runtimeconfig: all necessary APIs are enabled
+  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (1.25 KB) for uploading
+  functions: functions folder uploaded successfully
i  functions: updating function onProductCreated...
!  functions[onProductCreated]: Deployment error.
Failed to configure trigger providers/cloud.firestore/eventTypes/[email protected] (onProductCreated)

My Code:

const functions = require('firebase-functions');
const algoliasearch = require('algoliasearch');

// App ID and API Key are stored in functions config variables
const ALGOLIA_ID = functions.config().algolia.app_id;
const ALGOLIA_ADMIN_KEY = functions.config().algolia.api_key;

const ALGOLIA_INDEX_NAME = "Firestore";
const client = algoliasearch(ALGOLIA_ID, ALGOLIA_ADMIN_KEY);

// Update the search index every time a blog post is written.
exports.onProductCreated = functions.firestore
.document("Product Catalog/{id}")
.onCreate(event => {
  const product = event.data.data();
  product.objectID = event.params.postId;

  const index = client.initIndex(ALGOLIA_INDEX_NAME);
  return index.saveObject(product);
});

package.json:

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "serve": "firebase serve --only functions",
    "shell": "firebase experimental:functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "dependencies": {
    "@google-cloud/firestore": "^0.8.2",
    "algoliasearch": "^3.24.5",
    "firebase-admin": "~5.4.2",
    "firebase-functions": "^0.7.1"
  },
  "private": true
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...