Skip to content

Commit

Permalink
fixed db schema errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
yghokim committed Apr 26, 2020
1 parent 2ed911a commit 15d8e81
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions server/models/ot_tracker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as mongoose from 'mongoose';


const otFieldSchema = new mongoose.Schema({
_id: String, // this object id is not used as an index in server. it is only used in client.
name: String,
Expand All @@ -11,36 +10,36 @@ const otFieldSchema = new mongoose.Schema({
fallbackPreset: String,
type: Number,
isRequired: Boolean,
isHidden: {type: Boolean, default: false},
isInTrashcan: {type: Boolean, default: false},
properties: {type: mongoose.Schema.Types.Mixed, default: {}},
validators: {type: [{_id: false, type: String, params: {type: [mongoose.Schema.Types.Mixed], default: null}}], defualt: []},
isHidden: { type: Boolean, default: false },
isInTrashcan: { type: Boolean, default: false },
properties: { type: mongoose.Schema.Types.Mixed, default: {} },
validators: { type: [{ _id: false, type: { type: String, required: true }, params: { type: [mongoose.Schema.Types.Mixed], required: false, default: null } }], defualt: [] },
userCreatedAt: Number,
userUpdatedAt: Number,
lockedProperties: {type: mongoose.Schema.Types.Mixed, default: {}},
flags: {type: Object, default: {}},
}, {_id: false});
lockedProperties: { type: mongoose.Schema.Types.Mixed, default: {} },
flags: { type: Object, default: {} },
}, { _id: false });

const otTrackerSchema = new mongoose.Schema({
_id: {type: String},
_id: { type: String },
name: String,
color: Number,
user: {type: String, ref: 'OTUser'},
isBookmarked: {type: Boolean, default: false},
user: { type: String, ref: 'OTUser' },
isBookmarked: { type: Boolean, default: false },
position: Number,
fields: {type: [otFieldSchema], default: []},
lockedProperties: {type: mongoose.Schema.Types.Mixed, default: {}},
flags: {type: mongoose.Schema.Types.Mixed, default: {}},
redirectUrl: {type: String, default: null},
fields: { type: [otFieldSchema], default: [] },
lockedProperties: { type: mongoose.Schema.Types.Mixed, default: {} },
flags: { type: mongoose.Schema.Types.Mixed, default: {} },
redirectUrl: { type: String, default: null },
userCreatedAt: Number,
userUpdateAt: Number,
removed: {type: Boolean, index: true, default: false}
}, {timestamps: true});
removed: { type: Boolean, index: true, default: false }
}, { timestamps: true });

const OTTracker = mongoose.model('OTTracker', otTrackerSchema);

OTTracker.collection.createIndex({"flags.experiment": 1})
OTTracker.collection.createIndex({"flags.injectedId": 1})
OTTracker.collection.createIndex({ "flags.experiment": 1 })
OTTracker.collection.createIndex({ "flags.injectedId": 1 })


export default OTTracker;

0 comments on commit 15d8e81

Please sign in to comment.