mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.0 KiB
52 lines
1.0 KiB
7 years ago
|
|
||
7 years ago
|
/* global WIKI */
|
||
7 years ago
|
|
||
|
const gql = require('graphql')
|
||
|
|
||
|
module.exports = {
|
||
|
Query: {
|
||
|
files(obj, args, context, info) {
|
||
7 years ago
|
return WIKI.db.File.findAll({ where: args })
|
||
7 years ago
|
}
|
||
|
},
|
||
|
Mutation: {
|
||
|
uploadFile(obj, args) {
|
||
|
// todo
|
||
7 years ago
|
return WIKI.db.File.create(args)
|
||
7 years ago
|
},
|
||
|
deleteFile(obj, args) {
|
||
7 years ago
|
return WIKI.db.File.destroy({
|
||
7 years ago
|
where: {
|
||
|
id: args.id
|
||
|
},
|
||
|
limit: 1
|
||
|
})
|
||
|
},
|
||
|
renameFile(obj, args) {
|
||
7 years ago
|
return WIKI.db.File.update({
|
||
7 years ago
|
filename: args.filename
|
||
|
}, {
|
||
|
where: { id: args.id }
|
||
|
})
|
||
|
},
|
||
|
moveFile(obj, args) {
|
||
7 years ago
|
return WIKI.db.File.findById(args.fileId).then(fl => {
|
||
7 years ago
|
if (!fl) {
|
||
|
throw new gql.GraphQLError('Invalid File ID')
|
||
|
}
|
||
7 years ago
|
return WIKI.db.Folder.findById(args.folderId).then(fld => {
|
||
7 years ago
|
if (!fld) {
|
||
|
throw new gql.GraphQLError('Invalid Folder ID')
|
||
|
}
|
||
|
return fl.setFolder(fld)
|
||
|
})
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
File: {
|
||
|
folder(fl) {
|
||
|
return fl.getFolder()
|
||
|
}
|
||
|
}
|
||
|
}
|