{"action":"created","issue":{"url":"https://api.github.com/repos/marklogic/node-client-api/issues/201","labels_url":"https://api.github.com/repos/marklogic/node-client-api/issues/201/labels{/name}","comments_url":"https://api.github.com/repos/marklogic/node-client-api/issues/201/comments","events_url":"https://api.github.com/repos/marklogic/node-client-api/issues/201/events","html_url":"https://github.com/marklogic/node-client-api/issues/201","id":106832544,"number":201,"title":"Setting optimistic locking throws XDMP-UPDATEFUNCTIONFROMQUERY:","user":{"login":"csreddy","id":1539198,"avatar_url":"https://avatars.githubusercontent.com/u/1539198?v=3","gravatar_id":"","url":"https://api.github.com/users/csreddy","html_url":"https://github.com/csreddy","followers_url":"https://api.github.com/users/csreddy/followers","following_url":"https://api.github.com/users/csreddy/following{/other_user}","gists_url":"https://api.github.com/users/csreddy/gists{/gist_id}","starred_url":"https://api.github.com/users/csreddy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csreddy/subscriptions","organizations_url":"https://api.github.com/users/csreddy/orgs","repos_url":"https://api.github.com/users/csreddy/repos","events_url":"https://api.github.com/users/csreddy/events{/privacy}","received_events_url":"https://api.github.com/users/csreddy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"ehennum","id":1170070,"avatar_url":"https://avatars.githubusercontent.com/u/1170070?v=3","gravatar_id":"","url":"https://api.github.com/users/ehennum","html_url":"https://github.com/ehennum","followers_url":"https://api.github.com/users/ehennum/followers","following_url":"https://api.github.com/users/ehennum/following{/other_user}","gists_url":"https://api.github.com/users/ehennum/gists{/gist_id}","starred_url":"https://api.github.com/users/ehennum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ehennum/subscriptions","organizations_url":"https://api.github.com/users/ehennum/orgs","repos_url":"https://api.github.com/users/ehennum/repos","events_url":"https://api.github.com/users/ehennum/events{/privacy}","received_events_url":"https://api.github.com/users/ehennum/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2015-09-16T18:23:43Z","updated_at":"2015-10-13T20:54:59Z","closed_at":null,"body":"Not sure what I'm doing wrong. Here's what my code looks like:\r\n```javascript\r\n'use strict';\r\n\r\nvar fs = require('fs');\r\nvar flash = require('connect-flash');\r\nvar marklogic = require('marklogic');\r\nvar conn = require('../../config/db-config.js').connection;\r\nvar db = marklogic.createDatabaseClient(conn);\r\nvar q = marklogic.queryBuilder;\r\nvar p = marklogic.patchBuilder;\r\nvar async = require('async');\r\nvar request = require('request');\r\nvar _ = require('lodash');\r\nvar common = require('../common/common.controller');\r\nvar Notify = require('../../email/email').Notify;\r\n\r\nvar notify = new Notify();\r\n\r\n// enable optimistic locking, with version-optional\r\n// this is required to maintain integrity of nextid document\r\ndb.config.serverprops.write({\r\n    'update-policy': 'version-optional'\r\n})\r\n    .result(function(response) {\r\n        console.log('setting optimistic locking....');\r\n        console.log(JSON.stringify(response));\r\n    }).catch(function(error) {\r\n        console.log('OPTMISTIC LOCK ERROR', error);\r\n    });\r\n\r\n\r\n// Get list of items\r\nexports.index = function(req, res) {\r\n    res.send([]);\r\n};\r\n...\r\n...\r\n...\r\n```\r\n\r\nerror:\r\n```\r\nOPTMISTIC LOCK ERROR { [Error: write REST server properties: cannot process response with 500 status]\r\n  message: 'write REST server properties: cannot process response with 500 status',\r\n  statusCode: 500,\r\n  body:\r\n   { errorResponse:\r\n      { statusCode: 500,\r\n        status: 'Internal Server Error',\r\n        messageCode: 'INTERNAL ERROR',\r\n        message: 'XDMP-UPDATEFUNCTIONFROMQUERY: xdmp:apply(function() as item()*) -- Cannot apply an update function from a query . See the MarkLogic server error log for further detail.' } } }\r\n```"},"comment":{"url":"https://api.github.com/repos/marklogic/node-client-api/issues/comments/147850896","html_url":"https://github.com/marklogic/node-client-api/issues/201#issuecomment-147850896","issue_url":"https://api.github.com/repos/marklogic/node-client-api/issues/201","id":147850896,"user":{"login":"ehennum","id":1170070,"avatar_url":"https://avatars.githubusercontent.com/u/1170070?v=3","gravatar_id":"","url":"https://api.github.com/users/ehennum","html_url":"https://github.com/ehennum","followers_url":"https://api.github.com/users/ehennum/followers","following_url":"https://api.github.com/users/ehennum/following{/other_user}","gists_url":"https://api.github.com/users/ehennum/gists{/gist_id}","starred_url":"https://api.github.com/users/ehennum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ehennum/subscriptions","organizations_url":"https://api.github.com/users/ehennum/orgs","repos_url":"https://api.github.com/users/ehennum/repos","events_url":"https://api.github.com/users/ehennum/events{/privacy}","received_events_url":"https://api.github.com/users/ehennum/received_events","type":"User","site_admin":false},"created_at":"2015-10-13T20:54:59Z","updated_at":"2015-10-13T20:54:59Z","body":"Does the user have rest-admin privileges?"}}