2014-05-11 10:13:13 -04:00
|
|
|
c = require './../schemas'
|
|
|
|
|
2014-05-13 16:46:56 -04:00
|
|
|
# TODO add these: http://docs.mongodb.org/manual/reference/operator/query/
|
|
|
|
MongoQueryOperatorSchema =
|
|
|
|
title: 'MongoDB Query operator'
|
|
|
|
id: 'mongoQueryOperator'
|
|
|
|
type: 'object'
|
|
|
|
properties:
|
|
|
|
'$gt': type: 'number'
|
|
|
|
'$gte': type: 'number'
|
|
|
|
'$in': type: 'array'
|
|
|
|
'$lt': type: 'number'
|
|
|
|
'$lte': type: 'number'
|
2014-06-30 22:16:26 -04:00
|
|
|
'$ne': type: ['number', 'string']
|
2014-05-13 16:46:56 -04:00
|
|
|
'$nin': type: 'array'
|
2014-05-21 07:52:09 -04:00
|
|
|
additionalProperties: true # TODO set to false when the schema's done
|
|
|
|
|
|
|
|
MongoFindQuerySchema =
|
|
|
|
title: 'MongoDB Query'
|
|
|
|
id: 'mongoFindQuery'
|
|
|
|
type: 'object'
|
|
|
|
patternProperties:
|
2014-05-21 13:47:17 -04:00
|
|
|
#'^[-a-zA-Z0-9_]*$':
|
2014-05-24 14:45:53 -04:00
|
|
|
'^[-a-zA-Z0-9\.]*$':
|
2014-05-21 07:52:09 -04:00
|
|
|
oneOf: [
|
2014-06-30 22:16:26 -04:00
|
|
|
#{$ref: '#/definitions/' + MongoQueryOperatorSchema.id},
|
|
|
|
{type: 'string'},
|
|
|
|
{type: 'object'}
|
2014-05-21 07:52:09 -04:00
|
|
|
]
|
2014-05-24 14:45:53 -04:00
|
|
|
additionalProperties: true # TODO make Treema accept new pattern matched keys
|
2014-05-21 07:52:09 -04:00
|
|
|
definitions: {}
|
|
|
|
|
|
|
|
MongoFindQuerySchema.definitions[MongoQueryOperatorSchema.id] = MongoQueryOperatorSchema
|
|
|
|
|
2014-05-21 13:47:17 -04:00
|
|
|
AchievementSchema = c.object()
|
2014-05-21 07:52:09 -04:00
|
|
|
c.extendNamedProperties AchievementSchema
|
|
|
|
c.extendBasicProperties AchievementSchema, 'article'
|
|
|
|
c.extendSearchableProperties AchievementSchema
|
|
|
|
|
2014-05-21 13:47:17 -04:00
|
|
|
_.extend(AchievementSchema.properties,
|
|
|
|
query:
|
2014-05-22 10:59:01 -04:00
|
|
|
#type:'object'
|
|
|
|
$ref: '#/definitions/' + MongoFindQuerySchema.id
|
2014-06-30 22:16:26 -04:00
|
|
|
worth: {type: 'number'}
|
|
|
|
collection: {type: 'string'}
|
|
|
|
description: {type: 'string'}
|
|
|
|
userField: {type: 'string'}
|
2014-05-22 10:59:01 -04:00
|
|
|
related: c.objectId(description: 'Related entity')
|
2014-06-30 22:16:26 -04:00
|
|
|
icon: {type: 'string', format: 'image-file', title: 'Icon'}
|
2014-05-21 13:47:17 -04:00
|
|
|
proportionalTo:
|
|
|
|
type: 'string'
|
|
|
|
description: 'For repeatables only. Denotes the field a repeatable achievement needs for its calculations'
|
2014-05-31 17:19:55 -04:00
|
|
|
function:
|
|
|
|
type: 'object'
|
2014-06-03 06:40:47 -04:00
|
|
|
properties:
|
2014-06-14 14:12:17 -04:00
|
|
|
kind: {enum: ['linear', 'logarithmic', 'quadratic'], default: 'linear'}
|
2014-06-03 06:40:47 -04:00
|
|
|
parameters:
|
2014-05-31 17:19:55 -04:00
|
|
|
type: 'object'
|
|
|
|
properties:
|
|
|
|
a: {type: 'number', default: 1}
|
|
|
|
b: {type: 'number', default: 1}
|
2014-06-03 06:40:47 -04:00
|
|
|
c: {type: 'number', default: 1}
|
2014-06-14 14:12:17 -04:00
|
|
|
additionalProperties: true
|
2014-06-03 06:40:47 -04:00
|
|
|
default: {kind: 'linear', parameters: a: 1}
|
|
|
|
required: ['kind', 'parameters']
|
|
|
|
additionalProperties: false
|
2014-05-21 13:47:17 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
AchievementSchema.definitions = {}
|
|
|
|
AchievementSchema.definitions[MongoFindQuerySchema.id] = MongoFindQuerySchema
|
|
|
|
|
2014-05-21 07:52:09 -04:00
|
|
|
module.exports = AchievementSchema
|