mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
552-update_comment
This commit is contained in:
parent
f7ef09acbf
commit
7ddbab83e9
@ -40,6 +40,7 @@ export default {
|
||||
if (!post) {
|
||||
throw new UserInputError(NO_POST_ERR_MESSAGE)
|
||||
}
|
||||
|
||||
const comment = await neo4jgraphql(
|
||||
object,
|
||||
params,
|
||||
@ -67,7 +68,6 @@ export default {
|
||||
// Strip element tags and remove leading/trailing white spaces from content
|
||||
const content = params.content.replace(/<(?:.|\n)*?>/gm, '').trim()
|
||||
const { id } = params
|
||||
console.log(id)
|
||||
// Check length of content
|
||||
if (!params.content || content.length < COMMENT_MIN_LENGTH) {
|
||||
throw new UserInputError(
|
||||
@ -79,49 +79,47 @@ export default {
|
||||
const session = context.driver.session()
|
||||
const commentQueryRes = await session.run(
|
||||
`
|
||||
MATCH (comment: COMMENT)
|
||||
WHERE id(comment)=$id
|
||||
MATCH (comment: Comment { id:$id})
|
||||
RETURN comment`,
|
||||
{
|
||||
id
|
||||
}
|
||||
)
|
||||
console.log(id)
|
||||
console.log(commentQueryRes)
|
||||
|
||||
// Destructure content from session results array
|
||||
const [comment] = commentQueryRes.records.map(record => {
|
||||
console.log(record.get('comment'))
|
||||
const a = record.get('comment')
|
||||
console.log(a)
|
||||
return record.get('comment')
|
||||
})
|
||||
|
||||
// Send error message if cannot find a matching comment.
|
||||
// if (!comment) {
|
||||
// throw new UserInputError(NO_COMMENT_ERR_MESSAGE)
|
||||
// }
|
||||
if (!comment) {
|
||||
throw new UserInputError(NO_COMMENT_ERR_MESSAGE)
|
||||
}
|
||||
|
||||
// Update comment.
|
||||
// const commentRev = await neo4jgraphql(
|
||||
// object,
|
||||
// params,
|
||||
// context,
|
||||
// resolveInfo,
|
||||
// false
|
||||
// )
|
||||
const commentRev = await neo4jgraphql(
|
||||
object,
|
||||
params,
|
||||
context,
|
||||
resolveInfo,
|
||||
false
|
||||
)
|
||||
|
||||
// await session.run(
|
||||
// `
|
||||
// MATCH (comment:Comment)
|
||||
// WHERE id(comment)=$id,
|
||||
// SET comment.content = $content
|
||||
// `,
|
||||
// {
|
||||
// id,
|
||||
// content
|
||||
// }
|
||||
// )
|
||||
await session.run(
|
||||
`
|
||||
MATCH (comment: Comment { id:$id})
|
||||
SET comment.content = 'bbb'
|
||||
`,
|
||||
{
|
||||
id,
|
||||
content
|
||||
}
|
||||
)
|
||||
session.close()
|
||||
|
||||
// return commentRev
|
||||
return commentRev
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user