Skip to content

Commit

Permalink
feat(schema): add function and action on base schema
Browse files Browse the repository at this point in the history
  • Loading branch information
lykmapipo committed Dec 7, 2019
1 parent 5bef60d commit 25af8c0
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/changelog.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const SCHEMA = mergeObjects(
{ image, audio, video, document }
);

// TODO: all criteria use $in operator

/**
* @module ChangeLog
* @namespace ChangeLog
Expand Down
4 changes: 4 additions & 0 deletions src/event.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import {
PREDEFINE_OPTION_AUTOPOPULATE,
} from './internals';

// TODO: send notification after create
// TODO: calculate expose(risk) after create
// TODO: send actions after create

/**
* @module Event
* @namespace Event
Expand Down
92 changes: 92 additions & 0 deletions src/schema/base.schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,95 @@ export const type = {
aggregatable: { unwind: true },
default: undefined,
};

/**
* @name function
* @alias fanction
* @description Group event response activities(i.e actions)
*
* @memberof Event
* @memberof ChangeLog
*
* @type {object}
* @property {object} type - schema(data) type
* @property {boolean} required - mark required
* @property {boolean} index - ensure database index
* @property {boolean} exists - ensure ref exists before save
* @property {object} autopopulate - auto populate(eager loading) options
* @property {boolean} taggable - allow field use for tagging
* @property {boolean} exportable - allow field use for exporting
* @property {boolean} aggregatable - allow field use for aggregation
* @property {boolean} default - default value set when none provided
* @property {object} fake - fake data generator options
*
* @author lally elias <lallyelias87@gmail.com>
* @since 0.1.0
* @version 0.1.0
* @instance
* @example
* {
* _id: '5dde6ca33631a92c2d616298',
* strings: { name: { en: 'Communication and Warning' } },
* }
*/
export const fanction = {
type: ObjectId,
ref: Predefine.MODEL_NAME,
// required: true,
index: true,
exists: true,
autopopulate: PREDEFINE_OPTION_AUTOPOPULATE,
taggable: true,
exportable: {
format: v => get(v, 'strings.name.en'),
default: 'NA',
},
aggregatable: { unwind: true },
default: undefined,
};

/**
* @name action
* @alias action
* @description Define an event response activity.
*
* @memberof Event
* @memberof ChangeLog
*
* @type {object}
* @property {object} type - schema(data) type
* @property {boolean} required - mark required
* @property {boolean} index - ensure database index
* @property {boolean} exists - ensure ref exists before save
* @property {object} autopopulate - auto populate(eager loading) options
* @property {boolean} taggable - allow field use for tagging
* @property {boolean} exportable - allow field use for exporting
* @property {boolean} aggregatable - allow field use for aggregation
* @property {boolean} default - default value set when none provided
* @property {object} fake - fake data generator options
*
* @author lally elias <lallyelias87@gmail.com>
* @since 0.1.0
* @version 0.1.0
* @instance
* @example
* {
* _id: '5dde6ca33631a92c2d616298',
* strings: { name: { en: 'Disseminating warning information' } },
* }
*/
export const action = {
type: ObjectId,
ref: Predefine.MODEL_NAME,
// required: true,
index: true,
exists: true,
autopopulate: PREDEFINE_OPTION_AUTOPOPULATE,
taggable: true,
exportable: {
format: v => get(v, 'strings.name.en'),
default: 'NA',
},
aggregatable: { unwind: true },
default: undefined,
};

0 comments on commit 25af8c0

Please sign in to comment.