Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var mlclient = require('marklogic');
var qb = mlclient.queryBuilder;
var pb = mlclient.patchBuilder;
var meta = require('./meta');
var util = libRequire('db-client/util');
var funcs = {};
var moment = require('moment-timezone');
// funcs.exploreSearch = require('./exploreSearch');
funcs.patch = require('./patch');
funcs.search = function (spec) {
// TODO: should really be supporting the txid param
// query function wants an args list so we use apply since we
// are dynamically creating values out of what is specified
// console.log(require('util').inspect(this));
// console.log(JSON.stringify(spec));
return this.documents.query.apply(
this,
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Promise = require('bluebird');
var mlclient = require('marklogic');
var qb = mlclient.queryBuilder;
var pb = mlclient.patchBuilder;
var _ = require('lodash');
var uuid = require('node-uuid');
var db;
var questionsDir = '/questions/';
var contributorPrefix = 'com.marklogic.samplestack.domain.Contributor';
var contributorDir = contributorPrefix + '/';
// TODO: pull contributor info from session
var contributorId = 'cf99542d-f024-4478-a6dc-7e723a51b040';
var contributorDisplayName = 'JoeUser';
var contributorUserName = 'joe@example.com';
var commentTemplate = {
'owner': {
'id': contributorId,
'displayName': contributorDisplayName,
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var mlclient = require('marklogic');
var qb = mlclient.queryBuilder;
var pb = mlclient.patchBuilder;
var meta = require('./meta');
var util = libRequire('db-client/util');
var funcs = {};
/**
* Handle an update to a contributor's reputation by patch the document.
*
* @param {String} txid The transaction ID.
* @param {String} id The contributor ID.
* @param {Number} repChange Increment or decrement value.
* @return {Promise} A promise object.
*/
funcs.patchReputation = function (txid, id, repChange) {
// add (or subtract) from reputation property
return this.documents.patch({
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var mlclient = require('marklogic');
var qb = mlclient.queryBuilder;
var pb = mlclient.patchBuilder;
var meta = require('./meta');
var util = libRequire('db-client/util');
var errs = libRequire('errors');
var moment = require('moment-timezone');
var Promise = require('bluebird');
var qnaDoc = require('./index');
module.exports = function (txid, spec) {
var self = this;
/**
* Handles an upvote or downvote for a Samplestack question or answer.
* Performs three patch operations:
* 1. Adds the contributor ID to the array of upvoters or
* downvoters.