Cloud Functions-এর সাহায্যে, আপনি Cloud Firestore ডেটাবেসে পরিবর্তনের মাধ্যমে ট্রিগার করা ইভেন্ট ম্যানেজ করার জন্য কোড ডিপ্লয় করতে পারবেন। এর ফলে, আপনি নিজের সার্ভার না চালিয়েই অ্যাপে সহজেই সার্ভার-সাইড ফাংশনালিটি যোগ করতে পারবেন।
Cloud Functions (সেকেন্ড জেনারেশন)
Cloud Run এবং Eventarc দ্বারা পরিচালিত, Cloud Functions for Firebase (2nd gen) আপনাকে আরও শক্তিশালী ইনফ্রাস্ট্রাকচার, পারফর্ম্যান্স ও স্কেলেবিলিটির উপর উন্নত কন্ট্রোল এবং ফাংশন রানটাইমের উপর আরও বেশি কন্ট্রোল প্রদান করে। সেকেন্ড জেনারেশন সম্পর্কে আরও তথ্যের জন্য, Firebase-এর জন্য ক্লাউড ফাংশন (সেকেন্ড জেনারেশন) দেখুন। এর পরিবর্তে, ফার্স্ট জেনারেশন সম্পর্কে আরও জানতে, Cloud Functions-এর মাধ্যমে Cloud Firestore এক্সটেন্ড করুন দেখুন।
Cloud Firestore ফাংশন ট্রিগার
Cloud Functions for Firebase SDK নিম্নলিখিত Cloud Firestore ইভেন্ট ট্রিগার এক্সপোর্ট করে যাতে আপনি নির্দিষ্ট Cloud Firestore ইভেন্টের সাথে যুক্ত হ্যান্ডলার তৈরি করতে পারেন:
Node.js
| ইভেন্টের ধরন | Trigger |
|---|---|
onDocumentCreated |
প্রথমবার কোনও ডকুমেন্ট লেখা হলে ট্রিগার করা হয়। |
onDocumentUpdated |
ডকুমেন্ট আগে থেকেই থাকলে এবং কোনও ভ্যালু পরিবর্তন হলে ট্রিগার করা হয়। |
onDocumentDeleted |
কোনও ডকুমেন্ট মুছে ফেলা হলে ট্রিগার করা হয়। |
onDocumentWritten |
onDocumentCreated, onDocumentUpdated বা onDocumentDeleted ট্রিগার হলে ট্রিগার হয়। |
onDocumentCreatedWithAuthContext |
অতিরিক্ত যাচাইকরণ সংক্রান্ত তথ্য সহ onDocumentCreated |
onDocumentWrittenWithAuthContext |
অতিরিক্ত যাচাইকরণ সংক্রান্ত তথ্য সহ onDocumentWritten |
onDocumentDeletedWithAuthContext |
অতিরিক্ত যাচাইকরণ সংক্রান্ত তথ্য সহ onDocumentDeleted |
onDocumentUpdatedWithAuthContext |
অতিরিক্ত যাচাইকরণ সংক্রান্ত তথ্য সহ onDocumentUpdated |
Python
| ইভেন্টের ধরন | Trigger |
|---|---|
on_document_created |
প্রথমবার কোনও ডকুমেন্ট লেখা হলে ট্রিগার করা হয়। |
on_document_updated |
ডকুমেন্ট আগে থেকেই থাকলে এবং কোনও ভ্যালু পরিবর্তন হলে ট্রিগার করা হয়। |
on_document_deleted |
কোনও ডকুমেন্ট মুছে ফেলা হলে ট্রিগার করা হয়। |
on_document_written |
on_document_created, on_document_updated বা on_document_deleted ট্রিগার করা হলে ট্রিগার করা হয়। |
on_document_created_with_auth_context |
অতিরিক্ত যাচাইকরণ সংক্রান্ত তথ্য সহ on_document_created |
on_document_updated_with_auth_context |
অতিরিক্ত যাচাইকরণ সংক্রান্ত তথ্য সহ on_document_updated |
on_document_deleted_with_auth_context |
অতিরিক্ত যাচাইকরণ সংক্রান্ত তথ্য সহ on_document_deleted |
on_document_written_with_auth_context |
অতিরিক্ত যাচাইকরণ সংক্রান্ত তথ্য সহ on_document_written |
Cloud Firestore ইভেন্ট শুধুমাত্র ডকুমেন্টে পরিবর্তন হলে ট্রিগার হয়। Cloud Firestore ডকুমেন্টে কোনও আপডেট করা হলে, যেখানে ডেটা অপরিবর্তিত থাকে (একটি নো-অপ রাইট) সেখানে কোনও আপডেট বা রাইট ইভেন্ট তৈরি হয় না। নির্দিষ্ট ফিল্ডে ইভেন্ট যোগ করা সম্ভব নয়।
Cloud Functions for Firebase-এর জন্য আপনার কোনও প্রোজেক্ট চালু করা না থাকলে, Cloud Functions for Firebase (২য় জেনারেশন) ব্যবহার শুরু করুন পড়ুন এবং আপনার Cloud Functions for Firebase প্রোজেক্ট কনফিগার ও সেট-আপ করুন।
Cloud Firestore-ট্রিগার করা ফাংশন লেখা হচ্ছে
ফাংশন ট্রিগার নির্দিষ্ট করুন
Cloud Firestore ট্রিগার নির্ধারণ করতে, ডকুমেন্টের পাথ ও ইভেন্টের ধরন উল্লেখ করুন:
Node.js
const {
onDocumentWritten,
onDocumentCreated,
onDocumentUpdated,
onDocumentDeleted,
Change,
FirestoreEvent
} = require('firebase-functions/v2/firestore');
exports.myfunction = onDocumentWritten("my-collection/{docId}", (event) => {
/* ... */
});
Python
from firebase_functions.firestore_fn import (
on_document_created,
on_document_deleted,
on_document_updated,
on_document_written,
Event,
Change,
DocumentSnapshot,
)
@on_document_created(document="users/{userId}")
def myfunction(event: Event[DocumentSnapshot]) -> None:
ডকুমেন্ট পাথ নির্দিষ্ট ডকুমেন্ট অথবা ওয়াইল্ডকার্ড প্যাটার্ন রেফারেন্স হিসেবে ব্যবহার করতে পারে।
একটি ডকুমেন্ট নির্দিষ্ট করুন
আপনি যদি কোনও নির্দিষ্ট ডকুমেন্টে যেকোনও পরিবর্তনের জন্য কোনও ইভেন্ট ট্রিগার করতে চান, তাহলে আপনি নিম্নলিখিত ফাংশনটি ব্যবহার করতে পারেন।
Node.js
const {
onDocumentWritten,
Change,
FirestoreEvent
} = require('firebase-functions/v2/firestore');
exports.myfunction = onDocumentWritten("users/marie", (event) => {
// Your code here
});
Python
from firebase_functions.firestore_fn import (
on_document_written,
Event,
Change,
DocumentSnapshot,
)
@on_document_written(document="users/marie")
def myfunction(event: Event[Change[DocumentSnapshot]]) -> None:
ওয়াইল্ডকার্ড ব্যবহার করে ডকুমেন্টের একটি গ্রুপ নির্দিষ্ট করুন
আপনি যদি কোনও ডকুমেন্টের গ্রুপে ট্রিগার অ্যাটাচ করতে চান, যেমন কোনও নির্দিষ্ট কালেকশনের
যেকোনও ডকুমেন্ট, তাহলে ডকুমেন্ট আইডির পরিবর্তে
{wildcard} ব্যবহার করুন:
Node.js
const {
onDocumentWritten,
Change,
FirestoreEvent
} = require('firebase-functions/v2/firestore');
exports.myfunction = onDocumentWritten("users/{userId}", (event) => {
// If we set `/users/marie` to {name: "Marie"} then
// event.params.userId == "marie"
// ... and ...
// event.data.after.data() == {name: "Marie"}
});
Python
from firebase_functions.firestore_fn import (
on_document_written,
Event,
Change,
DocumentSnapshot,
)
@on_document_written(document="users/{userId}")
def myfunction(event: Event[Change[DocumentSnapshot]]) -> None:
# If we set `/users/marie` to {name: "Marie"} then
event.params["userId"] == "marie" # True
# ... and ...
event.data.after.to_dict() == {"name": "Marie"} # True
এই উদাহরণে, users-এর কোনও ডকুমেন্টের কোনও ফিল্ড পরিবর্তন করা হলে, সেটি userId নামক ওয়াইল্ডকার্ডের সাথে
ম্যাচ করে।
users-এর কোনও ডকুমেন্টে সাবকালেকশন থাকলে এবং সেই সাবকালেকশনের কোনও ডকুমেন্টের ফিল্ডে পরিবর্তন করা হলে, userId ওয়াইল্ডকার্ড ট্রিগার করা হয় না।
ডকুমেন্ট পাথ থেকে ওয়াইল্ডকার্ড ম্যাচ এক্সট্র্যাক্ট করে event.params-এ স্টোর করা হয়।
আপনি যতগুলি চান ততগুলি ওয়াইল্ডকার্ড সংজ্ঞায়িত করতে পারেন, উদাহরণস্বরূপ:
Node.js
const {
onDocumentWritten,
Change,
FirestoreEvent
} = require('firebase-functions/v2/firestore');
exports.myfunction = onDocumentWritten("users/{userId}/{messageCollectionId}/{messageId}", (event) => {
// If we set `/users/marie/incoming_messages/134` to {body: "Hello"} then
// event.params.userId == "marie";
// event.params.messageCollectionId == "incoming_messages";
// event.params.messageId == "134";
// ... and ...
// event.data.after.data() == {body: "Hello"}
});
Python
from firebase_functions.firestore_fn import (
on_document_written,
Event,
Change,
DocumentSnapshot,
)
@on_document_written(document="users/{userId}/{messageCollectionId}/{messageId}")
def myfunction(event: Event[Change[DocumentSnapshot]]) -> None:
# If we set `/users/marie/incoming_messages/134` to {body: "Hello"} then
event.params["userId"] == "marie" # True
event.params["messageCollectionId"] == "incoming_messages" # True
event.params["messageId"] == "134" # True
# ... and ...
event.data.after.to_dict() == {"body": "Hello"}
আপনি ওয়াইল্ডকার্ড ব্যবহার করলেও, আপনার ট্রিগার সবসময় কোনও ডকুমেন্টকে পয়েন্ট করতে হবে।
যেমন, users/{userId}/{messageCollectionId} সঠিক নয় কারণ {messageCollectionId}
হল একটি কালেকশন। তবে, users/{userId}/{messageCollectionId}/{messageId} হল
সঠিক কারণ {messageId} সবসময় কোনও ডকুমেন্টকে নির্দেশ করবে।
ইভেন্ট ট্রিগার
নতুন ডকুমেন্ট তৈরি করা হলে ফাংশন ট্রিগার করুন
কোনও কালেকশনে নতুন ডকুমেন্ট তৈরি করা হলে, আপনি যেকোনও সময় ফায়ার করার জন্য ফাংশন ট্রিগার করতে পারবেন। এই উদাহরণ ফাংশনটি প্রতিবার নতুন ব্যবহারকারীর প্রোফাইল যোগ করার সময় ট্রিগার করে:
Node.js
const {
onDocumentCreated,
Change,
FirestoreEvent
} = require('firebase-functions/v2/firestore');
exports.createuser = onDocumentCreated("users/{userId}", (event) => {
// Get an object representing the document
// e.g. {'name': 'Marie', 'age': 66}
const snapshot = event.data;
if (!snapshot) {
console.log("No data associated with the event");
return;
}
const data = snapshot.data();
// access a particular field as you would any JS property
const name = data.name;
// perform more operations ...
});
যাচাইকরণ সংক্রান্ত অতিরিক্ত তথ্যের জন্য, onDocumentCreatedWithAuthContext ব্যবহার করুন।
Python
from firebase_functions.firestore_fn import (
on_document_created,
Event,
DocumentSnapshot,
)
@on_document_created(document="users/{userId}")
def myfunction(event: Event[DocumentSnapshot]) -> None:
# Get a dictionary representing the document
# e.g. {'name': 'Marie', 'age': 66}
new_value = event.data.to_dict()
# Access a particular field as you would any dictionary
name = new_value["name"]
# Perform more operations ...
কোনও ডকুমেন্ট আপডেট করা হলে ফাংশন ট্রিগার করো
এছাড়াও, কোনও ডকুমেন্ট আপডেট করা হলে আপনি একটি ফাংশন ট্রিগার করতে পারেন। কোনও ব্যবহারকারী তার প্রোফাইল পরিবর্তন করলে এই উদাহরণ ফাংশনটি ফায়ার করে:
Node.js
const {
onDocumentUpdated,
Change,
FirestoreEvent
} = require('firebase-functions/v2/firestore');
exports.updateuser = onDocumentUpdated("users/{userId}", (event) => {
// Get an object representing the document
// e.g. {'name': 'Marie', 'age': 66}
const newValue = event.data.after.data();
// access a particular field as you would any JS property
const name = newValue.name;
// perform more operations ...
});
যাচাইকরণ সংক্রান্ত অতিরিক্ত তথ্যের জন্য, onDocumentUpdatedWithAuthContext ব্যবহার করুন।
Python
from firebase_functions.firestore_fn import (
on_document_updated,
Event,
Change,
DocumentSnapshot,
)
@on_document_updated(document="users/{userId}")
def myfunction(event: Event[Change[DocumentSnapshot]]) -> None:
# Get a dictionary representing the document
# e.g. {'name': 'Marie', 'age': 66}
new_value = event.data.after.to_dict()
# Access a particular field as you would any dictionary
name = new_value["name"]
# Perform more operations ...
কোনও ডকুমেন্ট মুছে ফেলা হলে একটি ফাংশন ট্রিগার করুন
এছাড়াও, কোনও ডকুমেন্ট মুছে দেওয়া হলে আপনি একটি ফাংশন ট্রিগার করতে পারবেন। ব্যবহারকারী তার প্রোফাইল মুছে দিলে এই উদাহরণ ফাংশনটি কাজ করে:
Node.js
const {
onDocumentDeleted,
Change,
FirestoreEvent
} = require('firebase-functions/v2/firestore');
exports.deleteuser = onDocumentDeleted("users/{userId}", (event) => {
// Get an object representing the document
// e.g. {'name': 'Marie', 'age': 66}
const snap = event.data;
const data = snap.data();
// perform more operations ...
});
যাচাইকরণ সংক্রান্ত অতিরিক্ত তথ্যের জন্য, onDocumentDeletedWithAuthContext ব্যবহার করুন।
Python
from firebase_functions.firestore_fn import (
on_document_deleted,
Event,
DocumentSnapshot,
)
@on_document_deleted(document="users/{userId}")
def myfunction(event: Event[DocumentSnapshot|None]) -> None:
# Perform more operations ...
ডকুমেন্টে করা সব পরিবর্তনের জন্য ফাংশন ট্রিগার করাও
কোন ধরনের ইভেন্ট ট্রিগার হচ্ছে তা নিয়ে আপনি চিন্তিত না হলে, "ডকুমেন্ট লেখা হয়েছে" ইভেন্ট ট্রিগার ব্যবহার করে Cloud Firestore ডকুমেন্টে হওয়া সব পরিবর্তন আপনি শুনতে পারবেন। কোনও ব্যবহারকারী তৈরি, আপডেট বা মুছে ফেলা হলে এই উদাহরণ ফাংশনটি ফায়ার করে:
Node.js
const {
onDocumentWritten,
Change,
FirestoreEvent
} = require('firebase-functions/v2/firestore');
exports.modifyuser = onDocumentWritten("users/{userId}", (event) => {
// Get an object with the current document values.
// If the document does not exist, it was deleted
const document = event.data.after.data();
// Get an object with the previous document values
const previousValues = event.data.before.data();
// perform more operations ...
});
যাচাইকরণ সংক্রান্ত অতিরিক্ত তথ্যের জন্য, onDocumentWrittenWithAuthContext ব্যবহার করুন।
Python
from firebase_functions.firestore_fn import (
on_document_written,
Event,
Change,
DocumentSnapshot,
)
@on_document_written(document="users/{userId}")
def myfunction(event: Event[Change[DocumentSnapshot | None]]) -> None:
# Get an object with the current document values.
# If the document does not exist, it was deleted.
document = (event.data.after.to_dict()
if event.data.after is not None else None)
# Get an object with the previous document values.
# If the document does not exist, it was newly created.
previous_values = (event.data.before.to_dict()
if event.data.before is not None else None)
# Perform more operations ...
ডেটা পড়া ও লেখা
কোনও ফাংশন ট্রিগার করা হলে, এটি ইভেন্ট সম্পর্কিত ডেটার একটি স্ন্যাপশট প্রদান করে। আপনি এই স্ন্যাপশট ব্যবহার করে ইভেন্ট ট্রিগার করা ডকুমেন্ট থেকে পড়তে বা তাতে লিখতে পারেন অথবা আপনার ডেটাবেসের অন্যান্য অংশ অ্যাক্সেস করতে Firebase অ্যাডমিন SDK ব্যবহার করতে পারেন।
ইভেন্ট ডেটা
রিডিং ডেটা
কোনও ফাংশন ট্রিগার করা হলে, আপনি হয়ত আপডেট করা হয়েছে এমন কোনও ডকুমেন্ট থেকে ডেটা পেতে চাইবেন
অথবা আপডেট করার আগে ডেটা পেতে চাইবেন। আপনি
event.data.before ব্যবহার করে আগের ডেটা পেতে পারেন, যাতে আপডেট করার আগে ডকুমেন্টের স্ন্যাপশট থাকে।
একইভাবে, event.data.after-এ আপডেট করার পরে ডকুমেন্টের স্ন্যাপশট স্টেট
থাকে।
Node.js
exports.updateuser2 = onDocumentUpdated("users/{userId}", (event) => {
// Get an object with the current document values.
// If the document does not exist, it was deleted
const newValues = event.data.after.data();
// Get an object with the previous document values
const previousValues = event.data.before.data();
});
Python
@on_document_updated(document="users/{userId}")
def myfunction(event: Event[Change[DocumentSnapshot]]) -> None:
# Get an object with the current document values.
new_value = event.data.after.to_dict()
# Get an object with the previous document values.
prev_value = event.data.before.to_dict()
আপনি অন্য যেকোনও অবজেক্টের মতো প্রপার্টি অ্যাক্সেস করতে পারবেন। অন্যথায়, নির্দিষ্ট ফিল্ড অ্যাক্সেস করতে আপনি
get ফাংশন ব্যবহার করতে পারেন:
Node.js
// Fetch data using standard accessors
const age = event.data.after.data().age;
const name = event.data.after.data()['name'];
// Fetch data using built in accessor
const experience = event.data.after.data.get('experience');
Python
# Get the value of a single document field.
age = event.data.after.get("age")
# Convert the document to a dictionary.
age = event.data.after.to_dict()["age"]
ডেটা লেখা
প্রতিটি ফাংশন ইনভোকেশন আপনার Cloud Firestore ডেটাবেসের নির্দিষ্ট ডকুমেন্টের সাথে সম্পর্কিত। আপনার ফাংশনে ফেরত আসা স্ন্যাপশটে আপনি সেই ডকুমেন্ট অ্যাক্সেস করতে পারবেন।
ডকুমেন্ট রেফারেন্সে update(), set() এবং remove()-এর মতো পদ্ধতি অন্তর্ভুক্ত থাকে
যাতে আপনি ফাংশন ট্রিগার করা ডকুমেন্টটি পরিবর্তন করতে পারেন।
Node.js
const {onDocumentUpdated} = require('firebase-functions/v2/firestore');
exports.countnamechanges = onDocumentUpdated('users/{userId}', (event) => {
// Retrieve the current and previous value
const data = event.data.after.data();
const previousData = event.data.before.data();
// We'll only update if the name has changed.
// This is crucial to prevent infinite loops.
if (data.name == previousData.name) {
return null;
}
// Retrieve the current count of name changes
let count = data.name_change_count;
if (!count) {
count = 0;
}
// Then return a promise of a set operation to update the count
return event.data.after.ref.set({
name_change_count: count + 1
}, {merge: true});
});
Python
@on_document_updated(document="users/{userId}")
def myfunction(event: Event[Change[DocumentSnapshot]]) -> None:
# Get the current and previous document values.
new_value = event.data.after
prev_value = event.data.before
# We'll only update if the name has changed.
# This is crucial to prevent infinite loops.
if new_value.get("name") == prev_value.get("name"):
return
# Retrieve the current count of name changes
count = new_value.to_dict().get("name_change_count", 0)
# Update the count
new_value.reference.update({"name_change_count": count + 1})
ব্যবহারকারীর পরিচয় যাচাইকরণ সংক্রান্ত তথ্য অ্যাক্সেস করুন
আপনি নিম্নলিখিত ইভেন্টের ধরনগুলির মধ্যে একটি ব্যবহার করলে, আপনি ইভেন্টটি ট্রিগার করা প্রিন্সিপাল সম্পর্কে ব্যবহারকারীর যাচাইকরণ তথ্য অ্যাক্সেস করতে পারবেন। এই তথ্যটি বেস ইভেন্টে ফেরত আসা তথ্যের অতিরিক্ত।
Node.js
onDocumentCreatedWithAuthContextonDocumentWrittenWithAuthContextonDocumentDeletedWithAuthContextonDocumentUpdatedWithAuthContext
Python
on_document_created_with_auth_contexton_document_updated_with_auth_contexton_document_deleted_with_auth_contexton_document_written_with_auth_context
যাচাইকরণের প্রসঙ্গে উপলভ্য ডেটা সম্পর্কে তথ্য পেতে, যাচাইকরণের প্রসঙ্গ দেখুন। নিম্নলিখিত উদাহরণ থেকে কীভাবে যাচাইকরণ সংক্রান্ত তথ্য পাওয়া যায় তা জানুন:
Node.js
const {onDocumentWrittenWithAuthContext} = require('firebase-functions/v2/firestore');
exports.syncUser = onDocumentWrittenWithAuthContext("users/{userId}", (event) => {
const snapshot = event.data.after;
if (!snapshot) {
console.log("No data associated with the event");
return;
}
const data = snapshot.data();
// retrieve auth context from event
const { authType, authId } = event;
let verified = false;
if (authType === "system") {
// system-generated users are automatically verified
verified = true;
} else if (authType === "unknown" || authType === "unauthenticated") {
// admin users from a specific domain are verified
if (authId.endsWith("@example.com")) {
verified = true;
}
}
return data.after.ref.set({
created_by: authId,
verified,
}, {merge: true});
});
Python
@on_document_updated_with_auth_context(document="users/{userId}")
def myfunction(event: Event[Change[DocumentSnapshot]]) -> None:
# Get the current and previous document values.
new_value = event.data.after
prev_value = event.data.before
# Get the auth context from the event
user_auth_type = event.auth_type
user_auth_id = event.auth_id
ট্রিগার ইভেন্টের বাইরের ডেটা
Cloud Functions বিশ্বস্ত পরিবেশে এক্সিকিউট করা। এগুলি আপনার প্রোজেক্টে পরিষেবা অ্যাকাউন্ট হিসেবে অনুমোদিত এবং আপনি Firebase Admin SDK ব্যবহার করে ডেটা পড়তে ও লিখতে পারবেন:
Node.js
const { initializeApp } = require('firebase-admin/app');
const { getFirestore, Timestamp, FieldValue } = require('firebase-admin/firestore');
initializeApp();
const db = getFirestore();
exports.writetofirestore = onDocumentWritten("some/doc", (event) => {
db.doc('some/otherdoc').set({ ... });
});
exports.writetofirestore = onDocumentWritten('users/{userId}', (event) => {
db.doc('some/otherdoc').set({
// Update otherdoc
});
});
Python
from firebase_admin import firestore, initialize_app
import google.cloud.firestore
initialize_app()
@on_document_written(document="some/doc")
def myfunction(event: Event[Change[DocumentSnapshot | None]]) -> None:
firestore_client: google.cloud.firestore.Client = firestore.client()
firestore_client.document("another/doc").set({
# ...
})
সীমাবদ্ধতা
Cloud Functions-এর জন্য Cloud Firestore ট্রিগারের নিম্নলিখিত সীমাবদ্ধতাগুলি মনে রাখবেন:
- Cloud Functions (ফার্স্ট জেনারেশন) Firestore নেটিভ মোডে আগে থেকে থাকা "(ডিফল্ট)" ডেটাবেসের পূর্বশর্ত। এটি Cloud Firestore নামের ডেটাবেস বা Datastore মোড সাপোর্ট করে না। এই ধরনের ক্ষেত্রে ইভেন্ট কনফিগার করতে Cloud Functions (২য় জেনারেশন) ব্যবহার করুন।
- Cloud Functions এবং Cloud Firestore ট্রিগার সহ ক্রস প্রোজেক্ট সেট-আপের ক্ষেত্রে সীমাবদ্ধতা আছে। Cloud Firestore ট্রিগার সেট-আপ করতে Cloud Functions একই প্রোজেক্টে থাকতে হবে।
- অর্ডার করার বিষয়ে কোনও গ্যারেন্টি দেওয়া হয় না। দ্রুত পরিবর্তন করলে অপ্রত্যাশিত ক্রমে ফাংশন ইনভোকেশন ট্রিগার হতে পারে।
- ইভেন্ট অন্তত একবার ডেলিভার করা হয়, তবে একটি ইভেন্টের ফলে একাধিক ফাংশন ইনভোকেশন হতে পারে। একবার-মাত্র মেকানিক্সের উপর নির্ভর করা এড়িয়ে চলুন এবং আইডেমপোটেন্ট ফাংশন লিখুন।
- Datastore মোডে Cloud Firestore-এর জন্য Cloud Functions (২য় জেনারেশন) প্রয়োজন। Cloud Functions (ফার্স্ট জেনারেশন)-এ Datastore মোড কাজ করে না।
- একটি ট্রিগার একটি ডেটাবেসের সাথে যুক্ত থাকে। আপনি এমন কোনও ট্রিগার তৈরি করতে পারবেন না যা একাধিক ডেটাবেসের সাথে ম্যাচ করে।
- কোনও ডেটাবেস মুছে দিলে, সেই ডেটাবেসের জন্য কোনও ট্রিগার অটোমেটিক মুছে যায় না। ট্রিগার ইভেন্ট ডেলিভার করা বন্ধ করে দেয়, তবে আপনি ট্রিগার মুছে না দেওয়া পর্যন্ত এটি থেকে যায়।
- কোনও মিলে যাওয়া ইভেন্ট সর্বাধিক অনুরোধের সাইজ অতিক্রম করলে, ইভেন্টটি Cloud Functions (ফার্স্ট জেনারেশন)-এ ডেলিভার করা নাও হতে পারে।
- অনুরোধের সাইজের কারণে ইভেন্ট ডেলিভার করা যায়নি, সেগুলি প্ল্যাটফর্ম লগে লগ করা হয় এবং প্রোজেক্টের জন্য লগ ব্যবহারের ক্ষেত্রে গণনা করা হয়।
- আপনি এই লগগুলি Logs Explorer-এ
errorতীব্রতার "ফার্স্ট জেনারেশনের জন্য সাইজ সীমা অতিক্রম করার কারণে ইভেন্ট Cloud ফাংশনে ডেলিভার করা যাচ্ছে না..." মেসেজের সাথে খুঁজে পেতে পারেন। আপনিfunctionNameফিল্ডের অধীনে ফাংশনের নাম খুঁজে পেতে পারেন। যদিreceiveTimestampফিল্ডটি এখনও এক ঘণ্টার মধ্যে থাকে, তাহলে আপনি টাইমস্ট্যাম্পের আগে এবং পরে একটি স্ন্যাপশট সহ প্রশ্ন করা ডকুমেন্টটি পড়ে প্রকৃত ইভেন্ট কন্টেন্ট অনুমান করতে পারেন। - এই ধরনের ক্যাডেন্স এড়াতে, আপনি এগুলি করতে পারেন:
- মাইগ্রেট করে Cloud Functions (সেকেন্ড জেনারেশন)-এ আপগ্রেড করুন
- ডকুমেন্টের সাইজ কমানো
- প্রশ্ন থেকে Cloud Functions মুছে দিন
- আপনি বাদ দেওয়া ব্যবহার করে লগিং বন্ধ করতে পারেন তবে মনে রাখবেন যে আপত্তিকর ইভেন্টগুলি এখনও ডেলিভার করা হবে না।