-
Notifications
You must be signed in to change notification settings - Fork 44
/
citySchema.js
50 lines (48 loc) · 912 Bytes
/
citySchema.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// load modules
const mongoose = require('mongoose');
const _ = require('lodash');
const async = require('async');
const progressBar = require('progress');
// create city schema
var citySchema = new mongoose.Schema({
cityId : {
type : String,
unique : true,
lowercase : true,
trim : true,
set : function(v){
return _.kebabCase(v);
}
},
cityName : {
type : String,
trim : true,
},
keywords : {
type : [String],
default : [],
set : function(v){
var kebabCity =_.kebabCase(v);
return _.split(kebabCity, '-');
}
},
stateId : {
type : String,
lowercase : true,
trim : true,
set : function(v){
return _.kebabCase(v);
}
},
stateName : {
type : String,
trim : true
}
},
{
timestamps : true,
toObject : {virtuals : true, getters:true},
toJSON : {virtuals : true, getters:true}
});
// export schema
module.exports = exports = citySchema;