Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mirera-db
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
mirera
mirera-db
Commits
0e2a6a51
Commit
0e2a6a51
authored
Apr 21, 2020
by
Никита Бесшапошников
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass logger to db
parent
c9a29a8b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
10 deletions
+9
-10
files.js
files.js
+5
-4
index.js
index.js
+4
-4
timetable.js
timetable.js
+0
-2
No files found.
files.js
View file @
0e2a6a51
"
use strict
"
;
const
logger
=
require
(
'
../libs/log
'
);
const
s2s
=
require
(
'
string-to-stream
'
);
module
.
exports
.
getModelFunctions
=
model
=>
{
module
.
exports
.
getModelFunctions
=
(
model
,
logger
)
=>
{
let
functions
=
{};
...
...
@@ -60,7 +59,8 @@ module.exports.getModelFunctions = model => {
let
fileInfo
=
await
model
.
findOne
({
_id
:
id
});
if
(
!
fileInfo
)
{
logger
.
warn
(
`File
${
id
}
not found in GridFs Model:
${
model
.
modelName
}
`
)
if
(
logger
)
logger
.
warn
(
`File
${
id
}
not found in GridFs Model:
${
model
.
modelName
}
`
)
return
Buffer
.
from
(
'
File not exists!
'
);
}
...
...
@@ -87,7 +87,8 @@ module.exports.getModelFunctions = model => {
let
info
=
await
model
.
findOne
({
_id
:
id
});
if
(
!
info
)
{
logger
.
warn
(
`File
${
id
}
not found in GridFs Model:
${
model
.
modelName
}
`
)
if
(
logger
)
logger
.
warn
(
`File
${
id
}
not found in GridFs Model:
${
model
.
modelName
}
`
)
return
;
}
...
...
index.js
View file @
0e2a6a51
...
...
@@ -7,7 +7,7 @@ const files = require('./files');
module
.
exports
.
connection
=
null
;
module
.
exports
.
connect
=
async
(
uri
,
options
)
=>
{
module
.
exports
.
connect
=
async
(
uri
,
options
,
logger
)
=>
{
options
=
options
||
{};
mongoose
.
set
(
'
useNewUrlParser
'
,
true
);
...
...
@@ -35,7 +35,7 @@ module.exports.connect = async (uri, options) => {
connection
:
mongoose
.
connection
});
module
.
exports
.
filesFS
=
files
.
getModelFunctions
(
filesFS
);
module
.
exports
.
filesFS
=
files
.
getModelFunctions
(
filesFS
,
logger
);
let
testingFS
=
gridFS
.
createModel
({
bucketName
:
'
testing
'
,
...
...
@@ -43,7 +43,7 @@ module.exports.connect = async (uri, options) => {
connection
:
mongoose
.
connection
});
module
.
exports
.
testingFS
=
files
.
getModelFunctions
(
testingFS
);
module
.
exports
.
testingFS
=
files
.
getModelFunctions
(
testingFS
,
logger
);
let
solutionFS
=
gridFS
.
createModel
({
bucketName
:
'
solution
'
,
...
...
@@ -51,7 +51,7 @@ module.exports.connect = async (uri, options) => {
connection
:
mongoose
.
connection
});
module
.
exports
.
solutionFS
=
files
.
getModelFunctions
(
solutionFS
);
module
.
exports
.
solutionFS
=
files
.
getModelFunctions
(
solutionFS
,
logger
);
module
.
exports
.
defines
=
require
(
'
./defines
'
)
module
.
exports
.
attachments
=
require
(
'
./attachment
'
);
...
...
timetable.js
View file @
0e2a6a51
...
...
@@ -2,8 +2,6 @@
const
mongoose
=
require
(
'
mongoose
'
);
const
defines
=
require
(
'
./defines
'
);
const
TimetableSchema
=
new
mongoose
.
Schema
({
course
:
{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment