يعمل كائن الخصائص كواجهة للوصول إلى خصائص المستخدم أو المستند أو النص البرمجي. يعتمد نوع السمة المحدّد على أي من الطرق الثلاث المستخدمة في PropertiesService
للنص البرمجي: PropertiesService.getDocumentProperties()
أو PropertiesService.getUserProperties()
أو PropertiesService.getScriptProperties()
.
ولا يمكن مشاركة الخصائص بين النصوص البرمجية. لمزيد من المعلومات عن أنواع المواقع، راجِع دليل خدمات المواقع.
الطُرق
الطريقة | نوع القيمة التي يتم إرجاعها | وصف قصير |
---|---|---|
deleteAllProperties() | Properties | سيؤدي ذلك إلى حذف جميع المواقع في متجر Properties الحالي. |
deleteProperty(key) | Properties | يؤدي هذا الإجراء إلى حذف الموقع الذي يتضمّن المفتاح المحدّد في متجر "Properties " الحالي. |
getKeys() | String[] | يمكن الحصول على جميع المفاتيح في متجر "Properties " الحالي. |
getProperties() | Object | الحصول على نسخة من كل أزواج المفتاح/القيمة في متجر Properties الحالي |
getProperty(key) | String | الحصول على القيمة المرتبطة بالمفتاح المحدّد في متجر Properties الحالي أو القيمة null في حال عدم توفّر هذا المفتاح |
setProperties(properties) | Properties | تحدِّد هذه السياسة كل أزواج المفتاح/القيمة من العنصر المحدّد في متجر Properties الحالي. |
setProperties(properties, deleteAllOthers) | Properties | تضبط هذه السياسة كل أزواج المفتاح/القيمة من العنصر المحدّد في مخزن Properties الحالي،
مع حذف جميع السمات الأخرى في المتجر اختياريًا. |
setProperty(key, value) | Properties | لضبط زوج المفتاح/القيمة المحدّد في متجر Properties الحالي. |
الوثائق التفصيلية
deleteAllProperties()
سيؤدي ذلك إلى حذف جميع المواقع في متجر Properties
الحالي.
// Deletes all user properties. var userProperties = PropertiesService.getUserProperties(); userProperties.deleteAllProperties();
استرجاع الكرة
Properties
- هذا المتجر من Properties
، للسلاسل
deleteProperty(key)
يؤدي هذا الإجراء إلى حذف الموقع الذي يتضمّن المفتاح المحدّد في متجر "Properties
" الحالي.
// Deletes the user property 'nickname'. var userProperties = PropertiesService.getUserProperties(); userProperties.deleteProperty('nickname');
المَعلمات
الاسم | Type | الوصف |
---|---|---|
key | String | مفتاح الخاصية لحذفها |
استرجاع الكرة
Properties
- هذا المتجر من Properties
، للسلاسل
getKeys()
يمكن الحصول على جميع المفاتيح في متجر "Properties
" الحالي.
// Sets several properties, then logs the value of each key. var scriptProperties = PropertiesService.getScriptProperties(); scriptProperties.setProperties({ 'cow': 'moo', 'sheep': 'baa', 'chicken': 'cluck' }); var keys = scriptProperties.getKeys(); Logger.log('Animals known:'); for (var i = 0; i < keys.length; i++) { Logger.log(keys[i]); }
استرجاع الكرة
String[]
- مجموعة من جميع المفاتيح في متجر Properties
الحالي
getProperties()
الحصول على نسخة من كل أزواج المفتاح/القيمة في متجر Properties
الحالي تجدر الإشارة إلى أنّ الكائن المعروض ليس عرضًا مباشرًا للمتجر. وبالتالي، لن يؤدي تغيير الخصائص في الكائن المعروض إلى تحديثها تلقائيًا في مساحة التخزين، والعكس صحيح.
// Sets several script properties, then retrieves them and logs them. var scriptProperties = PropertiesService.getScriptProperties(); scriptProperties.setProperties({ 'cow': 'moo', 'sheep': 'baa', 'chicken': 'cluck' }); var animalSounds = scriptProperties.getProperties(); // Logs: // A chicken goes cluck! // A cow goes moo! // A sheep goes baa! for (var kind in animalSounds) { Logger.log('A %s goes %s!', kind, animalSounds[kind]); }
استرجاع الكرة
Object
- نسخة من كل أزواج المفتاح/القيمة في متجر Properties
الحالي
getProperty(key)
الحصول على القيمة المرتبطة بالمفتاح المحدّد في متجر Properties
الحالي أو القيمة null
في حال عدم توفّر هذا المفتاح
// Gets the user property 'nickname'. var userProperties = PropertiesService.getUserProperties(); var nickname = userProperties.getProperty('nickname'); Logger.log(nickname);
المَعلمات
الاسم | Type | الوصف |
---|---|---|
key | String | مفتاح قيمة الخاصية لاسترداد |
استرجاع الكرة
String
: القيمة المرتبطة بالمفتاح المحدّد في متجر Properties
الحالي
setProperties(properties)
تحدِّد هذه السياسة كل أزواج المفتاح/القيمة من العنصر المحدّد في متجر Properties
الحالي.
// Sets multiple user properties at once. var userProperties = PropertiesService.getUserProperties(); var newProperties = {nickname: 'Bob', region: 'US', language: 'EN'}; userProperties.setProperties(newProperties);
المَعلمات
الاسم | Type | الوصف |
---|---|---|
properties | Object | كائن يحتوي على أزواج المفتاح/القيم المطلوب تعيينها |
استرجاع الكرة
Properties
- هذا المتجر من Properties
، للسلاسل
setProperties(properties, deleteAllOthers)
تضبط هذه السياسة كل أزواج المفتاح/القيمة من العنصر المحدّد في مخزن Properties
الحالي،
مع حذف جميع السمات الأخرى في المتجر اختياريًا.
// Sets multiple user properties at once while deleting all other user properties. var userProperties = PropertiesService.getUserProperties(); var newProperties = {nickname: 'Bob', region: 'US', language: 'EN'}; userProperties.setProperties(newProperties, true);
المَعلمات
الاسم | Type | الوصف |
---|---|---|
properties | Object | كائن يحتوي على أزواج المفتاح/القيم المطلوب تعيينها |
deleteAllOthers | Boolean | true لحذف جميع أزواج المفتاح/القيمة الأخرى في كائن الخصائص، فيما لا يمكن حذف false |
استرجاع الكرة
Properties
- هذا المتجر من Properties
، للسلاسل
setProperty(key, value)
لضبط زوج المفتاح/القيمة المحدّد في متجر Properties
الحالي.
// Sets the user property 'nickname' to 'Bobby'. var userProperties = PropertiesService.getUserProperties(); userProperties.setProperty('nickname', 'Bobby');
المَعلمات
الاسم | Type | الوصف |
---|---|---|
key | String | مفتاح الخاصية |
value | String | القيمة المطلوب ربطها بالمفتاح |
استرجاع الكرة
Properties
- هذا المتجر من Properties
، للسلاسل