FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
parse-server/GridStoreAdapter.js at master · mslsoftware/parse-server · GitHub
mslsoftware
/
parse-server
Public
forked from
parse-community/parse-server
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
parse-server
/
GridStoreAdapter.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (34 loc) · 1.05 KB
Breadcrumbs
parse-server
/
GridStoreAdapter.js
Copy path
File metadata and controls
38 lines (34 loc) · 1.05 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
// GridStoreAdapter
//
// Stores files in Mongo using GridStore
// Requires the database adapter to be based on mongoclient
var
GridStore
=
require
(
'mongodb'
)
.
GridStore
;
// For a given config object, filename, and data, store a file
// Returns a promise
function
create
(
config
,
filename
,
data
)
{
return
config
.
database
.
connect
(
)
.
then
(
(
)
=>
{
var
gridStore
=
new
GridStore
(
config
.
database
.
db
,
filename
,
'w'
)
;
return
gridStore
.
open
(
)
;
}
)
.
then
(
(
gridStore
)
=>
{
return
gridStore
.
write
(
data
)
;
}
)
.
then
(
(
gridStore
)
=>
{
return
gridStore
.
close
(
)
;
}
)
;
}
// Search for and return a file if found by filename
// Resolves a promise that succeeds with the buffer result
// from GridStore
function
get
(
config
,
filename
)
{
return
config
.
database
.
connect
(
)
.
then
(
(
)
=>
{
return
GridStore
.
exist
(
config
.
database
.
db
,
filename
)
;
}
)
.
then
(
(
)
=>
{
var
gridStore
=
new
GridStore
(
config
.
database
.
db
,
filename
,
'r'
)
;
return
gridStore
.
open
(
)
;
}
)
.
then
(
(
gridStore
)
=>
{
return
gridStore
.
read
(
)
;
}
)
;
}
module
.
exports
=
{
create
:
create
,
get
:
get
}
;
Back
|
FazBrowse Home
|
New Git URL