Sunday, 11 June 2017

Algolia Instant Search Firebase Cloud Function - how to get the other value?

I don't have much idea about JavaScript, so I used Algolia's Instant Search for Firebase Github Repository to build my own function.

My function:

exports.indexentry = functions.database.ref('/posts/{postid}/text').onWrite(event => {
  const index = client.initIndex(ALGOLIA_POSTS_INDEX_NAME);
  const firebaseObject = {
    text: event.data.val(),
   timestamp: event.data.val(),
    objectID: event.params.postid
  };

In Algolia indices, with timestamp as the key, I get the same value as in text field, but in Firebase backend timestamp is different. How to fix this?

I tried different statements to get timestamp value but couldn't.



via Bugs Buggy

No comments:

Post a Comment