Skip to content

Commit

Permalink
feat: add campaign criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
lykmapipo committed Jun 15, 2019
1 parent f0088af commit db43c81
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/campaign.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@


const { getString } = require('@lykmapipo/env');
const { model, Schema, SCHEMA_OPTIONS } = require('@lykmapipo/mongoose-common');
const {
model,
Schema,
Mixed,
SCHEMA_OPTIONS
} = require('@lykmapipo/mongoose-common');
const actions = require('mongoose-rest-actions');


Expand Down Expand Up @@ -139,6 +144,20 @@ const CampaignSchema = new Schema({
taggable: true,
fake: true
},

/**
* @name criteria
* @description Application specific conditions to query for recipients.
* @type {Object}
* @since 0.1.0
* @version 1.0.0
* @instance
*/
criteria: {
type: Mixed,
default: {},
fake: true
}
}, SCHEMA_OPTIONS);


Expand Down
10 changes: 10 additions & 0 deletions test/unit/campaign.schema.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,14 @@ describe('Campaign Schema', () => {
expect(channels.options.taggable).to.be.true;
expect(channels.options.fake).to.exist;
});

it('should have criteria field', () => {
const criteria = Campaign.path('criteria');

expect(criteria).to.exist;
expect(criteria).to.be.an.instanceof(SchemaTypes.Mixed);
expect(criteria.instance).to.be.equal('Mixed');
expect(criteria.options.default).to.exist;
expect(criteria.options.fake).to.exist;
});
});

0 comments on commit db43c81

Please sign in to comment.