Defining the strategy model
This commit is contained in:
1 parent
3695a6f47a
commit
3e4c6d6748
5 files changed
+177
-90
No files matched your search
@@ -1,60 +0,0 @@
|
||||
import mongoose, { Schema } from 'mongoose';
|
||||
import Plotter from './plotter';
|
||||
import Formula from './formula';
|
||||
import {
|
||||
UNPUBLISHED,
|
||||
EventStateEnum,
|
||||
} from '../enums/EventState';
|
||||
|
||||
const { ObjectId } = Schema.Types;
|
||||
|
||||
const eventSchema = new Schema({
|
||||
state: {
|
||||
type: String,
|
||||
enum: EventStateEnum,
|
||||
default: UNPUBLISHED,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
hostId: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
formulaId: {
|
||||
type: ObjectId,
|
||||
ref: Formula.modelName,
|
||||
},
|
||||
plotterId: {
|
||||
type: ObjectId,
|
||||
ref: Plotter.modelName,
|
||||
},
|
||||
prizes: [{
|
||||
rank: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
subPrize: [{
|
||||
condition: String,
|
||||
}],
|
||||
}],
|
||||
});
|
||||
|
||||
eventSchema.pre('find', function populate() {
|
||||
this.populate('formulaId').populate('plotterId');
|
||||
});
|
||||
eventSchema.post('save', (doc, next) => {
|
||||
doc.populate('formulaId').populate('plotterId').execPopulate().then(() => {
|
||||
next();
|
||||
});
|
||||
});
|
||||
eventSchema.post('findOneAndUpdate', (doc, next) => {
|
||||
doc.populate('formulaId').populate('plotterId').execPopulate().then(() => {
|
||||
next();
|
||||
});
|
||||
});
|
||||
|
||||
const Event = mongoose.model('Event', eventSchema);
|
||||
|
||||
export default Event;
|
||||
@@ -1,12 +0,0 @@
|
||||
import mongoose, { Schema } from 'mongoose';
|
||||
|
||||
const formulaSchema = new Schema({
|
||||
name: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
const Formula = mongoose.model('Formula', formulaSchema);
|
||||
|
||||
export default Formula;
|
||||
+3
-6
@@ -1,9 +1,6 @@
|
||||
import Plotter from './plotter';
|
||||
import Event from './event';
|
||||
import Formula from './formula';
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import Strategy from './strategy';
|
||||
|
||||
export {
|
||||
Event,
|
||||
Plotter,
|
||||
Formula,
|
||||
Strategy,
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
import mongoose, { Schema } from 'mongoose';
|
||||
|
||||
const plotterSchema = new Schema({
|
||||
name: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
const Plotter = mongoose.model('Plotter', plotterSchema);
|
||||
|
||||
export default Plotter;
|
||||
@@ -0,0 +1,174 @@
|
||||
import mongoose, { Schema } from 'mongoose';
|
||||
|
||||
const strategySchema = new Schema({
|
||||
fbId: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
strategies: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
entryPoint: {
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
},
|
||||
exitPoint: {
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
},
|
||||
sellPoint: {
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
},
|
||||
buyPoint: {
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
},
|
||||
stopLoss: {
|
||||
phases: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
},
|
||||
buyOrder: {
|
||||
phases: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
},
|
||||
sellOrder: {
|
||||
phases: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
situations: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
conditions: [{
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
code: {
|
||||
type: String,
|
||||
default: 'false',
|
||||
},
|
||||
}],
|
||||
}],
|
||||
}],
|
||||
},
|
||||
}],
|
||||
});
|
||||
|
||||
const Strategy = mongoose.model('Strategy', strategySchema);
|
||||
|
||||
export default Strategy;
|
||||
Reference in new issue
Block a user