Skip to content

Commit bd5aee3

Browse files
committed
chore: pick v2.2.0 changes
1 parent 8ba644e commit bd5aee3

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
### Bug Fixes
5757
* 修复了使用 masterKey 获取一个 object 后再次 save 可能会报 ACL 格式不正确的问题。
5858
59-
## 2.1.0 (2017-01-20)
59+
# 2.1.0 (2017-01-20)
6060
### Bug Fixes
6161
* 修复了 `File#toJSON` 序列化结果中缺失 objectId 等字段的问题
6262
* 修复了使用 `Query#containsAll`、`Query#containedIn` 或 `Query#notContainedIn` 方法传入大数组时查询结果可能为空的问题

src/utils/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ const ensureArray = target => {
6161

6262
const transformFetchOptions = ({ keys, include, includeACL } = {}) => {
6363
const fetchOptions = {};
64-
if (_.isArray(keys)) {
65-
fetchOptions.keys = keys.join(',');
64+
if (keys) {
65+
fetchOptions.keys = ensureArray(keys).join(',');
6666
}
67-
if (_.isArray(include)) {
68-
fetchOptions.include = include.join(',');
67+
if (include) {
68+
fetchOptions.include = ensureArray(include).join(',');
6969
}
7070
if (includeACL) {
7171
fetchOptions.returnACL = includeACL;

storage.d.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ declare namespace AV {
88
export var applicationKey: string;
99
export var masterKey: string;
1010

11+
interface FetchOptions {
12+
keys?: string | string[];
13+
include?: string | string[];
14+
includeACL?: boolean;
15+
}
16+
1117
export interface AuthOptions {
1218
/**
1319
* In Cloud Code and Node only, causes the Master Key to be used for this request.
@@ -126,15 +132,15 @@ declare namespace AV {
126132
static withURL(name: string, url: string): File;
127133
static createWithoutData(objectId: string): File;
128134

129-
destroy<T>(): Promise<T>;
130-
fetch<T>(options?: AuthOptions): Promise<T>;
135+
destroy(): Promise<void>;
136+
fetch(fetchOptions?: FetchOptions, options?: AuthOptions): Promise<File>;
131137
metaData(): any;
132138
metaData(metaKey: string): any;
133139
metaData(metaKey: string, metaValue: any): any;
134140
name(): string;
135141
ownerId(): string;
136142
url(): string;
137-
save<T>(options?: AuthOptions): Promise<T>;
143+
save(options?: AuthOptions): Promise<File>;
138144
setACL(acl?: ACL): any;
139145
size(): any;
140146
thumbnailURL(width: number, height: number): string;
@@ -255,7 +261,7 @@ declare namespace AV {
255261
destroy<T>(options?: Object.DestroyOptions): Promise<T>;
256262
dirty(attr: String): boolean;
257263
escape(attr: string): string;
258-
fetch<T>(fetchOptions?: any, options?: Object.FetchOptions): Promise<T>;
264+
fetch<T>(fetchOptions?: FetchOptions, options?: AuthOptions): Promise<T>;
259265
fetchWhenSave(enable: boolean): any;
260266
get(attr: string): any;
261267
getACL(): ACL;
@@ -281,8 +287,6 @@ declare namespace AV {
281287

282288
interface DestroyAllOptions extends AuthOptions { }
283289

284-
interface FetchOptions extends AuthOptions { }
285-
286290
interface SaveOptions extends AuthOptions, SilentOption, WaitOption { }
287291

288292
interface SaveAllOptions extends AuthOptions { }
@@ -441,6 +445,7 @@ declare namespace AV {
441445
greaterThanOrEqualTo(key: string, value: any): Query;
442446
include(key: string): Query;
443447
include(keys: string[]): Query;
448+
includeACL(value?: boolean): Query;
444449
lessThan(key: string, value: any): Query;
445450
lessThanOrEqualTo(key: string, value: any): Query;
446451
limit(n: number): Query;

0 commit comments

Comments
 (0)