mirror of
https://github.com/vale981/Vulcan
synced 2025-03-05 17:41:43 -05:00
devel - revert commits related to simpl-schema (#1537)
* Revert "add note link to issue in collection2 on mutation insert, remove debug console logs on mutation edit" This reverts commit7a15103de7
. * Revert "node simpl-schema + collection2-core: fix vote by specifying the right type of the array (dont use blackbox in the end!)" This reverts commite894c3224c
. * Revert "add graphql date type (fix problem with node simple schema), fix an update bug on date picker, add edit check on custom post item, add `blackbox: true` for arrays field (validation problem with simple-schema)" This reverts commit9d84fbec98
. * Revert "use node `simpl-schema` by aldeed to replace `meteor/aldeed:simple-schema` ; use the meteor collection2 core package as recommended" This reverts commit016935f4fa
. * revert before node-simple-schema, fix obj.hasOwnProperty undefined error thrown by simple-schema & collection2 * CustomPostsItem: check on renderActions; withDocument/List: pollInterval 20seconds by default; DateTime form component enhancement + GraphQLDate type
This commit is contained in:
parent
ad007ac003
commit
7f99b48953
22 changed files with 94 additions and 149 deletions
|
@ -42,5 +42,5 @@ accounts-password@1.3.3
|
|||
# accounts-twitter
|
||||
# accounts-facebook
|
||||
|
||||
# customization-demo
|
||||
# framework-demo
|
||||
customization-demo
|
||||
framework-demo
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
accounts-base@1.2.14
|
||||
accounts-password@1.3.3
|
||||
aldeed:collection2-core@2.0.0
|
||||
aldeed:collection2@2.10.0
|
||||
aldeed:collection2-core@1.2.0
|
||||
aldeed:schema-deny@1.1.0
|
||||
aldeed:schema-index@1.1.1
|
||||
aldeed:simple-schema@1.5.3
|
||||
allow-deny@1.0.5
|
||||
autoupdate@1.3.12
|
||||
babel-compiler@6.13.0
|
||||
|
@ -15,6 +19,8 @@ callback-hook@1.0.10
|
|||
check@1.2.4
|
||||
chuangbo:cookie@1.1.0
|
||||
coffeescript@1.11.1_4
|
||||
customization-demo@0.0.0
|
||||
dburles:collection-helpers@1.1.0
|
||||
ddp@1.2.5
|
||||
ddp-client@1.3.2
|
||||
ddp-common@1.2.8
|
||||
|
@ -28,6 +34,7 @@ ejson@1.0.13
|
|||
email@1.1.18
|
||||
fortawesome:fontawesome@4.5.0
|
||||
fourseven:scss@3.10.1
|
||||
framework-demo@0.0.0
|
||||
geojson-utils@1.0.10
|
||||
hot-code-push@1.0.4
|
||||
html-tools@1.0.11
|
||||
|
@ -41,6 +48,7 @@ jquery@1.11.10
|
|||
livedata@1.0.18
|
||||
localstorage@1.0.12
|
||||
logging@1.1.16
|
||||
mdg:validation-error@0.5.1
|
||||
meteor@1.6.0
|
||||
meteor-base@1.0.4
|
||||
meteorhacks:fast-render@2.16.0
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
"formsy-react": "^0.18.1",
|
||||
"formsy-react-components": "^0.8.1",
|
||||
"graphql": "^0.8.2",
|
||||
"graphql-date": "^1.0.2",
|
||||
"graphql-server-express": "^0.4.4",
|
||||
"graphql-subscriptions": "^0.2.1",
|
||||
"graphql-tag": "^1.2.1",
|
||||
|
@ -58,7 +57,6 @@
|
|||
"redux": "^3.6.0",
|
||||
"rss": "^1.2.1",
|
||||
"sanitize-html": "^1.11.4",
|
||||
"simpl-schema": "^0.1.0",
|
||||
"speakingurl": "^9.0.0",
|
||||
"tracker-component": "^1.3.14",
|
||||
"url": "^0.11.0"
|
||||
|
|
|
@ -4,10 +4,9 @@ Posts.addField(
|
|||
{
|
||||
fieldName: 'categories',
|
||||
fieldSchema: {
|
||||
type: Array,
|
||||
type: [String],
|
||||
control: "checkboxgroup",
|
||||
optional: true,
|
||||
blackbox: true,
|
||||
insertableBy: ['members'],
|
||||
editableBy: ['members'],
|
||||
viewableBy: ['guests'],
|
||||
|
@ -39,7 +38,12 @@ Posts.addField(
|
|||
return categoriesOptions;
|
||||
}
|
||||
},
|
||||
// publish: true,
|
||||
// join: {
|
||||
// joinAs: "categoriesArray",
|
||||
// collection: () => Categories
|
||||
// },
|
||||
resolveAs: 'categories: [Category]'
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
|
|
@ -37,12 +37,16 @@ Posts.addField([
|
|||
{
|
||||
fieldName: "commenters",
|
||||
fieldSchema: {
|
||||
type: Array,
|
||||
blackbox: true,
|
||||
type: [String],
|
||||
optional: true,
|
||||
publish: true,
|
||||
// join: {
|
||||
// joinAs: "commentersArray",
|
||||
// collection: () => Users,
|
||||
// limit: 4
|
||||
// },
|
||||
resolveAs: 'commenters: [User]',
|
||||
viewableBy: ['guests'],
|
||||
}
|
||||
},
|
||||
}
|
||||
]);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import SimpleSchema from 'simpl-schema';
|
||||
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||
|
||||
const Events = new Mongo.Collection('events');
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ You also need to load Bootstrap's CSS separately.
|
|||
Example schema:
|
||||
|
||||
```js
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
|
||||
import BodyFormControl from './components/BodyFormControl.jsx';
|
||||
|
||||
const isLoggedIn = (user) => !!user;
|
||||
|
|
|
@ -9,12 +9,12 @@ class DateTime extends Component {
|
|||
|
||||
this.updateDate = this.updateDate.bind(this);
|
||||
}
|
||||
|
||||
|
||||
// when the datetime picker has mounted, SmartForm will catch the date value (no formsy mixin in this component)
|
||||
componentDidMount() {
|
||||
this.updateDate(this.props.value || new Date());
|
||||
}
|
||||
|
||||
|
||||
updateDate(date) {
|
||||
this.context.updateCurrentValue(this.props.name, date);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import SimpleSchema from 'simpl-schema';
|
||||
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||
|
||||
if (typeof SimpleSchema !== "undefined") {
|
||||
SimpleSchema.extendOptions({
|
||||
|
|
|
@ -15,7 +15,8 @@ Package.onUse(function(api) {
|
|||
|
||||
'ecmascript',
|
||||
'check',
|
||||
'aldeed:collection2-core@2.0.0',
|
||||
'aldeed:simple-schema@1.5.3',
|
||||
'aldeed:collection2@2.8.0',
|
||||
'fourseven:scss@3.8.0'
|
||||
]);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import SimpleSchema from 'simpl-schema';
|
||||
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||
import { GraphQLSchema } from './graphql.js';
|
||||
import { Utils } from './utils.js';
|
||||
import { runCallbacks } from './callbacks.js';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import SimpleSchema from 'simpl-schema';
|
||||
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||
|
||||
/**
|
||||
* @summary Kick off the global namespace for Telescope.
|
||||
|
|
|
@ -7,25 +7,24 @@ Utilities to generate the app's GraphQL schema
|
|||
import deepmerge from 'deepmerge';
|
||||
import GraphQLJSON from 'graphql-type-json';
|
||||
import GraphQLDate from 'graphql-date';
|
||||
|
||||
import { Utils } from './utils.js';
|
||||
|
||||
// convert a JSON schema to a GraphQL schema
|
||||
const jsTypeToGraphQLType = type => {
|
||||
switch (type) {
|
||||
case String:
|
||||
return "String";
|
||||
case Date:
|
||||
return "Date";
|
||||
case Number:
|
||||
const jsTypeToGraphQLType = typeName => {
|
||||
switch (typeName) {
|
||||
case "Number":
|
||||
return "Float";
|
||||
case Boolean:
|
||||
return "Boolean";
|
||||
|
||||
// assume all arrays contains strings for now
|
||||
case Array:
|
||||
case "Array":
|
||||
return "[String]";
|
||||
case Object:
|
||||
default:
|
||||
|
||||
case "Object":
|
||||
return "???";
|
||||
|
||||
default:
|
||||
return typeName;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,12 +89,13 @@ export const GraphQLSchema = {
|
|||
|
||||
// backward-compatibility code: we do not want user.telescope fields in the graphql schema
|
||||
const schema = Utils.stripTelescopeNamespace(collection.simpleSchema()._schema);
|
||||
|
||||
|
||||
let mainSchema = [], inputSchema = [], unsetSchema = [];
|
||||
|
||||
_.forEach(schema, (field, key) => {
|
||||
// console.log(field, key)
|
||||
const fieldType = jsTypeToGraphQLType(field.type.definitions[0].type);
|
||||
const fieldType = jsTypeToGraphQLType(field.type.name);
|
||||
|
||||
if (key.indexOf('$') === -1 && fieldType !== "???") { // skip fields with "$" and unknown fields
|
||||
|
||||
// 1. main schema
|
||||
|
|
|
@ -1,25 +1,14 @@
|
|||
import { getSetting } from './settings.js';
|
||||
|
||||
/*
|
||||
|
||||
Babel polyfill for SimpleSchema. See https://github.com/aldeed/node-simple-schema/issues/33
|
||||
|
||||
*/
|
||||
Array.includes = function() {
|
||||
let [first, ...rest] = arguments;
|
||||
return Array.prototype.includes.apply(first, rest);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
intl polyfill. See https://github.com/andyearnshaw/Intl.js/
|
||||
|
||||
*/
|
||||
|
||||
const areIntlLocalesSupported = require('intl-locales-supported');
|
||||
import { getSetting } from './settings.js';
|
||||
|
||||
const localesMyAppSupports = [
|
||||
var areIntlLocalesSupported = require('intl-locales-supported');
|
||||
|
||||
var localesMyAppSupports = [
|
||||
getSetting("locale", "en")
|
||||
];
|
||||
|
||||
|
@ -28,11 +17,11 @@ if (global.Intl) {
|
|||
if (!areIntlLocalesSupported(localesMyAppSupports)) {
|
||||
// `Intl` exists, but it doesn't have the data we need, so load the
|
||||
// polyfill and replace the constructors with need with the polyfill's.
|
||||
const IntlPolyfill = require('intl');
|
||||
var IntlPolyfill = require('intl');
|
||||
Intl.NumberFormat = IntlPolyfill.NumberFormat;
|
||||
Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat;
|
||||
}
|
||||
} else {
|
||||
// No `Intl`, so use and load the polyfill.
|
||||
global.Intl = require('intl');
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import './settings.js';
|
|||
import './collections.js';
|
||||
import './deep.js';
|
||||
import './deep_extend.js';
|
||||
import './polyfills.js';
|
||||
import './intl-polyfill.js';
|
||||
import './graphql.js';
|
||||
import './icons.js';
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ If the mutation call is not trusted (i.e. it comes from a GraphQL mutation),
|
|||
we'll run all validate steps:
|
||||
|
||||
- Check that the current user has permission to insert/edit each field.
|
||||
- Validate document against collection schema.
|
||||
- Add userId to document (insert only).
|
||||
- Run validation callbacks.
|
||||
|
||||
|
@ -35,6 +34,9 @@ export const newMutation = ({ collection, document, currentUser, validate, conte
|
|||
console.log("// newMutation")
|
||||
console.log(collection._name)
|
||||
console.log(document)
|
||||
|
||||
// we don't want to modify the original document
|
||||
let newDocument = Object.assign({}, document);
|
||||
|
||||
const collectionName = collection._name;
|
||||
const schema = collection.simpleSchema()._schema;
|
||||
|
@ -43,23 +45,20 @@ export const newMutation = ({ collection, document, currentUser, validate, conte
|
|||
if (validate) {
|
||||
|
||||
// check that the current user has permission to insert each field
|
||||
_.keys(document).forEach(function (fieldName) {
|
||||
_.keys(newDocument).forEach(function (fieldName) {
|
||||
var field = schema[fieldName];
|
||||
if (!context.Users.canInsertField (currentUser, field)) {
|
||||
throw new Meteor.Error('disallowed_property', `disallowed_property_detected: ${fieldName}`);
|
||||
}
|
||||
});
|
||||
|
||||
// validate document against schema
|
||||
collection.simpleSchema().namedContext(`${collectionName}.new`).validate(document);
|
||||
|
||||
// run validation callbacks
|
||||
document = runCallbacks(`${collectionName}.new.validate`, document, currentUser);
|
||||
newDocument = runCallbacks(`${collectionName}.new.validate`, newDocument, currentUser);
|
||||
}
|
||||
|
||||
// check if userId field is in the schema and add it to document if needed
|
||||
const userIdInSchema = Object.keys(schema).find(key => key === 'userId');
|
||||
if (!!userIdInSchema && !document.userId) document.userId = currentUser._id;
|
||||
if (!!userIdInSchema && !newDocument.userId) newDocument.userId = currentUser._id;
|
||||
|
||||
// TODO: find that info in GraphQL mutations
|
||||
// if (Meteor.isServer && this.connection) {
|
||||
|
@ -68,23 +67,22 @@ export const newMutation = ({ collection, document, currentUser, validate, conte
|
|||
// }
|
||||
|
||||
// run sync callbacks
|
||||
document = runCallbacks(`${collectionName}.new.sync`, document, currentUser);
|
||||
newDocument = runCallbacks(`${collectionName}.new.sync`, newDocument, currentUser);
|
||||
|
||||
// add _id to document
|
||||
// note: use {...document} to "enable" Object.prototype (see https://cl.ly/1N1m2d0y3u1A)
|
||||
// see https://github.com/aldeed/meteor-collection2-core/issues/8
|
||||
document._id = collection.insert({...document});
|
||||
newDocument._id = collection.insert(newDocument);
|
||||
|
||||
// get fresh copy of document from db
|
||||
const newDocument = collection.findOne(document._id);
|
||||
const insertedDocument = collection.findOne(newDocument._id);
|
||||
|
||||
// run async callbacks
|
||||
// note: query for document to get fresh document with collection-hooks effects applied
|
||||
runCallbacksAsync(`${collectionName}.new.async`, newDocument, currentUser);
|
||||
|
||||
runCallbacksAsync(`${collectionName}.new.async`, insertedDocument, currentUser);
|
||||
|
||||
console.log("// new mutation finished:")
|
||||
console.log(newDocument)
|
||||
return document;
|
||||
|
||||
return newDocument;
|
||||
}
|
||||
|
||||
export const editMutation = ({ collection, documentId, set, unset, currentUser, validate, context }) => {
|
||||
|
@ -100,7 +98,7 @@ export const editMutation = ({ collection, documentId, set, unset, currentUser,
|
|||
|
||||
// build mongo modifier from arguments
|
||||
let modifier = {$set: set, $unset: unset};
|
||||
|
||||
|
||||
// get original document from database
|
||||
let document = collection.findOne(documentId);
|
||||
|
||||
|
@ -110,15 +108,12 @@ export const editMutation = ({ collection, documentId, set, unset, currentUser,
|
|||
// check that the current user has permission to edit each field
|
||||
const modifiedProperties = _.keys(set).concat(_.keys(unset));
|
||||
modifiedProperties.forEach(function (fieldName) {
|
||||
const field = schema[fieldName];
|
||||
var field = schema[fieldName];
|
||||
if (!context.Users.canEditField(currentUser, field, document)) {
|
||||
throw new Meteor.Error('disallowed_property', `disallowed_property_detected: ${fieldName}`);
|
||||
}
|
||||
});
|
||||
|
||||
// validate modifier against schema
|
||||
collection.simpleSchema().namedContext(`${collectionName}.edit`).validate(modifier, {modifier: true});
|
||||
|
||||
// run validation callbacks
|
||||
modifier = runCallbacks(`${collectionName}.edit.validate`, modifier, document, currentUser);
|
||||
}
|
||||
|
|
|
@ -32,9 +32,10 @@ Package.onUse(function (api) {
|
|||
|
||||
// Third-party packages
|
||||
|
||||
'aldeed:collection2-core@2.0.0',
|
||||
'aldeed:simple-schema@1.5.3',
|
||||
'aldeed:collection2@2.10.0',
|
||||
'meteorhacks:picker@1.0.3',
|
||||
// 'dburles:collection-helpers@1.0.4',
|
||||
'dburles:collection-helpers@1.0.4',
|
||||
'percolatestudio:synced-cron@1.1.0',
|
||||
'jparker:gravatar@0.4.1',
|
||||
// 'kadira:flow-router-ssr@3.13.0',
|
||||
|
|
|
@ -19,7 +19,7 @@ const Meteor = typeof Meteor !== "undefined" ? Meteor : {
|
|||
methods: returnEmptyObject
|
||||
};
|
||||
|
||||
// const SimpleSchema = typeof SimpleSchema !== "undefined" ? SimpleSchema : returnEmptyObject;
|
||||
const SimpleSchema = typeof SimpleSchema !== "undefined" ? SimpleSchema : returnEmptyObject;
|
||||
|
||||
const Foo = "bar"
|
||||
export { Mongo, Foo }
|
||||
|
|
|
@ -13,8 +13,7 @@ Users.addField([
|
|||
{
|
||||
fieldName: '__subscribers',
|
||||
fieldSchema: {
|
||||
type: Array,
|
||||
blackbox: true,
|
||||
type: [String],
|
||||
optional: true,
|
||||
hidden: true, // never show this,
|
||||
// publish: true,
|
||||
|
@ -41,8 +40,7 @@ if (typeof Package['nova:posts'] !== "undefined") {
|
|||
{
|
||||
fieldName: 'subscribers',
|
||||
fieldSchema: {
|
||||
type: Array,
|
||||
blackbox: true,
|
||||
type: [String],
|
||||
optional: true,
|
||||
hidden: true, // never show this
|
||||
// publish: true,
|
||||
|
@ -71,8 +69,7 @@ if (typeof Package['nova:categories'] !== "undefined") {
|
|||
{
|
||||
fieldName: 'subscribers',
|
||||
fieldSchema: {
|
||||
type: Array,
|
||||
blackbox: true,
|
||||
type: [String],
|
||||
optional: true,
|
||||
hidden: true, // never show this
|
||||
// publish: true,
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import SimpleSchema from 'simpl-schema';
|
||||
import Users from './collection.js';
|
||||
|
||||
const adminGroup = {
|
||||
|
@ -27,12 +26,7 @@ const schema = {
|
|||
preload: true,
|
||||
},
|
||||
emails: {
|
||||
type: Array,
|
||||
blackbox: true,
|
||||
optional: true,
|
||||
},
|
||||
"emails.$": {
|
||||
type: Object,
|
||||
type: [Object],
|
||||
optional: true,
|
||||
},
|
||||
"emails.$.address": {
|
||||
|
@ -144,6 +138,7 @@ const schema = {
|
|||
*/
|
||||
__karma: {
|
||||
type: Number,
|
||||
decimal: true,
|
||||
publish: true,
|
||||
optional: true,
|
||||
viewableBy: ['guests'],
|
||||
|
@ -189,8 +184,7 @@ const schema = {
|
|||
Groups
|
||||
*/
|
||||
__groups: {
|
||||
type: Array,
|
||||
blackbox: true,
|
||||
type: [String],
|
||||
optional: true,
|
||||
control: "checkboxgroup",
|
||||
insertableBy: ['admins'],
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import SimpleSchema from 'simpl-schema';
|
||||
import Users from "meteor/nova:users";
|
||||
import Posts from "meteor/nova:posts";
|
||||
import Comments from "meteor/nova:comments";
|
||||
|
@ -28,77 +27,52 @@ Users.addField([
|
|||
{
|
||||
fieldName: '__upvotedComments',
|
||||
fieldSchema: {
|
||||
type: Array,
|
||||
type: [voteSchema],
|
||||
publish: false,
|
||||
optional: true,
|
||||
viewableBy: ['guests'],
|
||||
resolveAs: '__upvotedComments: [Vote]',
|
||||
}
|
||||
},
|
||||
{
|
||||
fieldName: "__upvotedComments.$",
|
||||
fieldSchema: {
|
||||
type: voteSchema,
|
||||
}
|
||||
},
|
||||
/**
|
||||
An array containing posts upvotes
|
||||
*/
|
||||
{
|
||||
fieldName: '__upvotedPosts',
|
||||
fieldSchema: {
|
||||
type: Array,
|
||||
type: [voteSchema],
|
||||
publish: false,
|
||||
optional: true,
|
||||
viewableBy: ['guests'],
|
||||
resolveAs: '__upvotedPosts: [Vote]',
|
||||
}
|
||||
},
|
||||
{
|
||||
fieldName: "__upvotedPosts.$",
|
||||
fieldSchema: {
|
||||
type: voteSchema,
|
||||
}
|
||||
},
|
||||
/**
|
||||
An array containing comment downvotes
|
||||
*/
|
||||
{
|
||||
fieldName: '__downvotedComments',
|
||||
fieldSchema: {
|
||||
type: Array,
|
||||
type: [voteSchema],
|
||||
publish: false,
|
||||
optional: true,
|
||||
viewableBy: ['guests'],
|
||||
resolveAs: '__downvotedComments: [Vote]',
|
||||
}
|
||||
},
|
||||
{
|
||||
fieldName: "__downvotedComments.$",
|
||||
fieldSchema: {
|
||||
type: voteSchema,
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
An array containing posts downvotes
|
||||
*/
|
||||
{
|
||||
fieldName: '__downvotedPosts',
|
||||
fieldSchema: {
|
||||
type: Array,
|
||||
type: [voteSchema],
|
||||
publish: false,
|
||||
optional: true,
|
||||
viewableBy: ['guests'],
|
||||
resolveAs: '__downvotedPosts: [Vote]',
|
||||
}
|
||||
},
|
||||
{
|
||||
fieldName: "__downvotedPosts.$",
|
||||
fieldSchema: {
|
||||
type: voteSchema,
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
Posts.addField([
|
||||
|
@ -121,19 +95,13 @@ Posts.addField([
|
|||
{
|
||||
fieldName: "upvoters",
|
||||
fieldSchema: {
|
||||
type: Array,
|
||||
type: [String],
|
||||
optional: true,
|
||||
publish: true,
|
||||
viewableBy: ['guests'],
|
||||
resolveAs: 'upvoters: [User]',
|
||||
}
|
||||
},
|
||||
{
|
||||
fieldName: "upvoters.$",
|
||||
fieldSchema: {
|
||||
type: String,
|
||||
}
|
||||
},
|
||||
/**
|
||||
How many downvotes the post has received
|
||||
*/
|
||||
|
@ -153,20 +121,13 @@ Posts.addField([
|
|||
{
|
||||
fieldName: "downvoters",
|
||||
fieldSchema: {
|
||||
type: Array,
|
||||
type: [String],
|
||||
optional: true,
|
||||
publish: true,
|
||||
viewableBy: ['guests'],
|
||||
resolveAs: 'downvoters: [User]',
|
||||
}
|
||||
},
|
||||
{
|
||||
fieldName: "downvoters.$",
|
||||
fieldSchema: {
|
||||
type: String,
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
The post's base score (not factoring in the post's age)
|
||||
*/
|
||||
|
@ -174,6 +135,7 @@ Posts.addField([
|
|||
fieldName: "baseScore",
|
||||
fieldSchema: {
|
||||
type: Number,
|
||||
decimal: true,
|
||||
optional: true,
|
||||
publish: true,
|
||||
defaultValue: 0,
|
||||
|
@ -187,6 +149,7 @@ Posts.addField([
|
|||
fieldName: "score",
|
||||
fieldSchema: {
|
||||
type: Number,
|
||||
decimal: true,
|
||||
optional: true,
|
||||
publish: true,
|
||||
defaultValue: 0,
|
||||
|
@ -215,19 +178,13 @@ Comments.addField([
|
|||
{
|
||||
fieldName: "upvoters",
|
||||
fieldSchema: {
|
||||
type: Array,
|
||||
type: [String],
|
||||
optional: true,
|
||||
publish: true,
|
||||
viewableBy: ['guests'],
|
||||
resolveAs: 'upvoters: [User]',
|
||||
}
|
||||
},
|
||||
{
|
||||
fieldName: "upvoters.$",
|
||||
fieldSchema: {
|
||||
type: String,
|
||||
}
|
||||
},
|
||||
/**
|
||||
The number of downvotes the comment has received
|
||||
*/
|
||||
|
@ -247,19 +204,13 @@ Comments.addField([
|
|||
{
|
||||
fieldName: "downvoters",
|
||||
fieldSchema: {
|
||||
type: Array,
|
||||
type: [String],
|
||||
optional: true,
|
||||
publish: true,
|
||||
viewableBy: ['guests'],
|
||||
resolveAs: 'downvoters: [User]',
|
||||
}
|
||||
},
|
||||
{
|
||||
fieldName: "downvoters.$",
|
||||
fieldSchema: {
|
||||
type: String,
|
||||
}
|
||||
},
|
||||
/**
|
||||
The comment's base score (not factoring in the comment's age)
|
||||
*/
|
||||
|
@ -267,6 +218,7 @@ Comments.addField([
|
|||
fieldName: "baseScore",
|
||||
fieldSchema: {
|
||||
type: Number,
|
||||
decimal: true,
|
||||
optional: true,
|
||||
publish: true,
|
||||
defaultValue: 0,
|
||||
|
@ -280,6 +232,7 @@ Comments.addField([
|
|||
fieldName: "score",
|
||||
fieldSchema: {
|
||||
type: Number,
|
||||
decimal: true,
|
||||
optional: true,
|
||||
publish: true,
|
||||
defaultValue: 0,
|
||||
|
@ -287,3 +240,4 @@ Comments.addField([
|
|||
}
|
||||
},
|
||||
]);
|
||||
|
||||
|
|
|
@ -21,4 +21,4 @@ const hasDownvoted = (user, document) => {
|
|||
return user && document.downvoters && !!document.downvoters.find(u => typeof u === 'string' ? u === user._id : u._id === user._id);
|
||||
};
|
||||
|
||||
export { hasUpvoted, hasDownvoted }
|
||||
export { hasUpvoted, hasDownvoted }
|
Loading…
Add table
Reference in a new issue