-
-
Notifications
You must be signed in to change notification settings - Fork 96
/
gridfs.ts
109 lines (92 loc) 路 2.6 KB
/
gridfs.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { Binary, Document, ObjectId } from "../../deps.ts";
import { ReadPreference } from "../types.ts";
import { ReadConcern, WriteConcern } from "../types/read_write_concern.ts";
export type FileId = ObjectId;
export interface Chunk {
_id: ObjectId;
// deno-lint-ignore camelcase
files_id: ObjectId;
n: number;
data: Binary;
}
export interface File {
_id: ObjectId;
length: number;
chunkSize: number;
uploadDate: Date;
filename: string;
metadata?: Document;
}
export interface GridFSBucketOptions {
/**
* The bucket name. Defaults to 'fs'.
*/
bucketName?: string;
/**
* The chunk size in bytes. Defaults to 255 KiB.
*/
chunkSizeBytes?: number;
/**
* The write concern. Defaults to the write concern of the database.
*/
writeConcern?: WriteConcern;
/**
* The read concern. Defaults to the read concern of the database.
*/
readConcern?: ReadConcern;
/**
* The read preference. Defaults to the read preference of the database.
*/
readPreference?: ReadPreference;
}
export interface GridFSUploadOptions {
/**
* The number of bytes per chunk of this file. Defaults to the
* chunkSizeBytes in the GridFSBucketOptions.
*/
chunkSizeBytes?: number;
/**
* User data for the 'metadata' field of the files collection document.
* If not provided the driver MUST omit the metadata field from the
* files collection document.
*/
metadata?: Document;
}
export class GridFSFindOptions {
/**
* Enables writing to temporary files on the server. When set to true, the server
* can write temporary data to disk while executing the find operation on the files collection.
*
* This option is sent only if the caller explicitly provides a value. The default
* is to not send a value. For servers < 3.2, this option is ignored and not sent
* as allowDiskUse does not exist in the OP_QUERY wire protocol.
*
* @see https://docs.mongodb.com/manual/reference/command/find/
*/
allowDiskUse?: boolean;
/**
* The number of documents to return per batch.
*/
batchSize?: number;
/**
* The maximum number of documents to return.
*/
limit?: number;
/**
* The maximum amount of time to allow the query to run.
*/
maxTimeMS?: number;
/**
* The server normally times out idle cursors after an inactivity period (10 minutes)
* to prevent excess memory use. Set this option to prevent that.
*/
noCursorTimeout?: boolean;
/**
* The number of documents to skip before returning.
*/
skip?: number;
/**
* The order by which to sort results. Defaults to not sorting.
*/
sort?: Document;
}