用户
已弃用。此类已废弃,不应在新脚本中使用。
用户属性是用户独有的键值对。用户属性的范围是按用户划分的;在用户身份下运行的任何脚本只能访问该用户的用户属性。
已弃用的方法
| 方法 | 返回类型 | 简介 | 
|---|---|---|
|  |  | 删除所有媒体资源。 | 
|  |  | 删除具有给定键的媒体资源。 | 
|  | String[] | 获取所有可用按键。 | 
|  | Object | 一次性获取所有可用媒体资源。 | 
|  | String | 返回与所提供键关联的值;如果没有此类值,则返回 null。 | 
|  |  | 批量设置从给定对象中提取的所有属性。 | 
|  |  | 批量设置从给定对象中提取的所有属性。 | 
|  |  | 使用提供的键保留指定的 in 值。 | 
已弃用的方法
delete
delete已弃用。此函数已废弃,不应在新脚本中使用。
删除所有媒体资源。
UserProperties .deleteAllProperties();
返回
User
另请参阅
delete
delete已弃用。此函数已废弃,不应在新脚本中使用。
删除具有给定键的媒体资源。
UserProperties .deleteProperty('special');
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| key | String | 要删除的媒体资源的键 | 
返回
User
另请参阅
get
get已弃用。此函数已废弃,不应在新脚本中使用。
获取所有可用按键。
返回
String[]
get
get已弃用。此函数已废弃,不应在新脚本中使用。
一次性获取所有可用媒体资源。
这会返回一个副本,而不是实时视图,因此更改返回对象的属性不会更新存储空间中的属性,反之亦然。
UserProperties .setProperties({ "cow" : "moo", "sheep" : "baa", "chicken" : "cluck" }); // Logs "A cow goes: moo" Logger.log("A cow goes: %s", UserProperties.getProperty("cow")); // This makes a copy. Any changes that happen here will not // be written back to properties. var animalSounds = UserProperties.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 - 包含键值对的属性的副本
get
get已弃用。此函数已废弃,不应在新脚本中使用。
返回与所提供键关联的值;如果没有此类值,则返回 null。
const specialValue = UserProperties.getProperty('special');
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| key | String | 要检索的值的键 | 
返回
String - 与键关联的值
另请参阅
set
set已弃用。此函数已废弃,不应在新脚本中使用。
批量设置从给定对象中提取的所有属性。
UserProperties .setProperties({special: 'sauce', 'meaning': 42});
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| properties | Object | 包含要设置的属性的对象。 | 
返回
User
另请参阅
set
set已弃用。此函数已废弃,不应在新脚本中使用。
批量设置从给定对象中提取的所有属性。
// This deletes all other properties UserProperties.setProperties({special: 'sauce', 'meaning': 42}, true);
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| properties | Object | 包含要设置的属性的对象。 | 
| delete | Boolean | 是否删除所有现有媒体资源。 | 
返回
User
另请参阅
set
set已弃用。此函数已废弃,不应在新脚本中使用。
使用提供的键保留指定的 in 值。与此键关联的任何现有值都将被覆盖。
UserProperties .setProperty('special', 'sauce');
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| key | String | 媒体资源的键 | 
| value | String | 要与键关联的值 | 
返回
User