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) {
|
if (!post) {
|
||||||
throw new UserInputError(NO_POST_ERR_MESSAGE)
|
throw new UserInputError(NO_POST_ERR_MESSAGE)
|
||||||
}
|
}
|
||||||
|
|
||||||
const comment = await neo4jgraphql(
|
const comment = await neo4jgraphql(
|
||||||
object,
|
object,
|
||||||
params,
|
params,
|
||||||
@ -67,7 +68,6 @@ export default {
|
|||||||
// Strip element tags and remove leading/trailing white spaces from content
|
// Strip element tags and remove leading/trailing white spaces from content
|
||||||
const content = params.content.replace(/<(?:.|\n)*?>/gm, '').trim()
|
const content = params.content.replace(/<(?:.|\n)*?>/gm, '').trim()
|
||||||
const { id } = params
|
const { id } = params
|
||||||
console.log(id)
|
|
||||||
// Check length of content
|
// Check length of content
|
||||||
if (!params.content || content.length < COMMENT_MIN_LENGTH) {
|
if (!params.content || content.length < COMMENT_MIN_LENGTH) {
|
||||||
throw new UserInputError(
|
throw new UserInputError(
|
||||||
@ -79,49 +79,47 @@ export default {
|
|||||||
const session = context.driver.session()
|
const session = context.driver.session()
|
||||||
const commentQueryRes = await session.run(
|
const commentQueryRes = await session.run(
|
||||||
`
|
`
|
||||||
MATCH (comment: COMMENT)
|
MATCH (comment: Comment { id:$id})
|
||||||
WHERE id(comment)=$id
|
|
||||||
RETURN comment`,
|
RETURN comment`,
|
||||||
{
|
{
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
console.log(id)
|
|
||||||
console.log(commentQueryRes)
|
|
||||||
// Destructure content from session results array
|
// Destructure content from session results array
|
||||||
const [comment] = commentQueryRes.records.map(record => {
|
const [comment] = commentQueryRes.records.map(record => {
|
||||||
console.log(record.get('comment'))
|
const a = record.get('comment')
|
||||||
|
console.log(a)
|
||||||
return record.get('comment')
|
return record.get('comment')
|
||||||
})
|
})
|
||||||
|
|
||||||
// Send error message if cannot find a matching comment.
|
// Send error message if cannot find a matching comment.
|
||||||
// if (!comment) {
|
if (!comment) {
|
||||||
// throw new UserInputError(NO_COMMENT_ERR_MESSAGE)
|
throw new UserInputError(NO_COMMENT_ERR_MESSAGE)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Update comment.
|
// Update comment.
|
||||||
// const commentRev = await neo4jgraphql(
|
const commentRev = await neo4jgraphql(
|
||||||
// object,
|
object,
|
||||||
// params,
|
params,
|
||||||
// context,
|
context,
|
||||||
// resolveInfo,
|
resolveInfo,
|
||||||
// false
|
false
|
||||||
// )
|
)
|
||||||
|
|
||||||
// await session.run(
|
await session.run(
|
||||||
// `
|
`
|
||||||
// MATCH (comment:Comment)
|
MATCH (comment: Comment { id:$id})
|
||||||
// WHERE id(comment)=$id,
|
SET comment.content = 'bbb'
|
||||||
// SET comment.content = $content
|
`,
|
||||||
// `,
|
{
|
||||||
// {
|
id,
|
||||||
// id,
|
content
|
||||||
// content
|
}
|
||||||
// }
|
)
|
||||||
// )
|
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
// return commentRev
|
return commentRev
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user