API রেফারেন্স

নীচে টাইপস্ক্রিপ্ট সংজ্ঞা এবং বিশদ বিবরণ সহ বান্ডেল বিল্ডার API-এর স্পেসিফিকেশনগুলির একটি ওভারভিউ রয়েছে৷

বান্ডেল ডকুমেন্ট ইন্টারফেস

কনফিগার করা সংগ্রহের মধ্যে একটি একক নথির জন্য স্পেসিফিকেশন:

type BundleDocument = {
  // A list of document IDs to serve in the bundle.
  docs?: Array<string>;
  // A map containing individual named queries and their definitions.
  queries?: Map<string, QueryDefinition[]>;
  // A map of parameters and their definitions, which can be provided to a query definition.
  params?: Map<string, ParamDefinition>;
  // Specifies how long to keep the bundle in the client's cache, in seconds. If not defined, client-side cache is disabled.
  clientCache?: string;
  // Only used in combination with Firebase Hosting. Specifies how long to keep the bundle in Firebase Hosting CDN cache, in seconds.
  serverCache: string;
  // Specifies how long (in seconds) to keep the bundle in a Cloud Storage bucket, in seconds. If not defined, Cloud Storage bucket is not accessed.
  fileCache?: string;
  // If a 'File Cache' is specified, bundles created before this timestamp will not be file cached.
  notBefore?: Timestamp;
};

প্যারাম ডেফিনিশন ইন্টারফেস

একটি BundleDocument এ সংজ্ঞায়িত একটি একক প্যারামিটারের স্পেসিফিকেশন।

type ParamDefinition = {
  // Whether this parameter is required. If not provided as a query string, an error will be thrown.
  required: boolean;
  // The type of value which will be parsed, defaults to 'string'.
  type?:
    | "string"
    | "integer"
    | "float"
    | "boolean"
    | "string-array"
    | "integer-array"
    | "float-array";
};

উদাহরণস্বরূপ, নিম্নলিখিত পরামিতি দেওয়া:

params: {
  name: {
    required: true,
    type: 'string',
  }
}

বান্ডেল HTTP এন্ডপয়েন্টে একটি অনুরোধ করার সময়, প্যারামিটারটি একটি ক্যোয়ারী প্যারামিটারের মাধ্যমে প্রদান করা যেতে পারে, যেমন ?name=david । প্যারামিটারটি একটি QueryDefinition (নীচে দেখুন) মান ( $name ) এর মধ্যে ব্যবহার করা যেতে পারে যা গতিশীলভাবে বান্ডেল তৈরি করতে পারে।

কোয়েরি ডেফিনিশন ইন্টারফেস

একটি ক্যোয়ারী সংজ্ঞা বান্ডেলে নামযুক্ত প্রশ্ন তৈরি করতে ব্যবহৃত হয়। queries ম্যাপের মধ্যে থাকা প্রতিটি অবজেক্ট নাম হিসাবে অবজেক্ট কী ব্যবহার করে একটি নতুন নামযুক্ত ক্যোয়ারী তৈরি করবে। প্রতিটি ক্যোয়ারী একটি সংগ্রহ নির্দিষ্ট করতে হবে, এবং ঐচ্ছিকভাবে সঞ্চালনের জন্য ক্যোয়ারী শর্তগুলির একটি তালিকা।

type QueryDefinition = {
  // The collection to perform the query on.
  collection: string;
  // An optional list of conditions to perform on the specified collection.
  conditions?: QueryCondition[];
};

conditions প্যারামিটারে QueryCondition ইন্টারফেসের একটি অ্যারে থাকতে পারে। অ্যারের প্রতিটি আইটেম শুধুমাত্র একটি একক শর্ত অন্তর্ভুক্ত করা আবশ্যক.

type QueryCondition = {
  // Performs a `where` filter on the collection on a given FieldPath, operator and value.
  where?: [
    string,
    (
      | "<"
      | "<="
      | "=="
      | ">="
      | ">"
      | "!="
      | "array-contains"
      | "in"
      | "not-in"
      | "array-contains-any"
    ),
    any
  ];
  orderBy?: [string, ("asc" | "desc")?];
  limit?: number;
  limitToLast?: number;
  offset?: number;
  startAt?: string;
  startAfter?: string;
  endAt?: string;
  endBefore?: string;
};

উদাহরণস্বরূপ, কোথায় এবং সীমা শর্ত সহ একটি products সংগ্রহে "পণ্য" নামে একটি প্রশ্ন তৈরি করতে, ডেটা স্ট্রাকচার আউটপুট নিম্নলিখিতগুলির সাথে মেলে:

queries: {
  products: {
    collection: 'products',
    conditions: [
      { where: ['type', '==', 'featured'] },
      { limit: 10 },
    ],
  }
}

, not-in in বা array-contains-any ফিল্টারে অ্যারে মান প্রদান করার সময়, আপনাকে অবশ্যই একটি কমা পৃথক মান প্রদান করতে হবে কারণ নেস্টেড অ্যারের মানগুলি Firestore-এ সমর্থিত নয়। উদাহরণ স্বরূপ:

{ where: ['category', 'in', 'womens,shorts'] }, // ['womens', 'shorts']

যেকোনো সংখ্যার মান একটি সংখ্যা হিসাবে পার্স করা হবে, তবে যদি একটি স্ট্রিং নম্বর মান প্রয়োজন হয় তবে এটি বন্ধনীতে মোড়ানো উচিত:

{ where: ['price', 'in', '1,2.5'] }, // [1, 2.5]
{ where: ['price', 'in', '"1","2.5"'] }, // ['1', '2.5']

শর্তগুলিও পরামিতিগুলির পাশাপাশি ব্যবহার করা যেতে পারে। উদাহরণস্বরূপ, যদি একটি প্যারামিটারের type সংজ্ঞায়িত করা হয় (উপরে দেখুন), এটি $ সিনট্যাক্সের মাধ্যমে গতিশীল ডেটা বান্ডেল সরবরাহ করার জন্য একটি শর্ত মান প্রদান করা যেতে পারে:

// ?type=featured


    conditions: [
      { where: ['type', '==', '$type'] },