为什么某些值不包含在csv-export中?

时间:2019-02-18 16:23:07

标签: mongodb

我正在尝试从mongodb导出csv:

mongoexport --host localhost --db booliscraper --collection sold --query='{"location.namedAreas":"_id,Hägersten",constructionYear: {$lt: 1980}, objectType: "Lägenhet"}' --type=csv --fields '_id,listPrice,livingArea,soldDays,' > sold.csv

对于某些值,sellPrice缺失:

ObjectId(5beca65c78f21248ab483320),4495000,63,456,
ObjectId(5beca65e78f21248ab483330),2350000,53,455,
ObjectId(5beca66678f21248ab483464),3195000,52,448,
ObjectId(5beca66978f21248ab4834ab),2495000,47,447,
ObjectId(5beca66f78f21248ab48354d),,42,442,
ObjectId(5beca67078f21248ab483570),5795000,85,442,
ObjectId(5beca67578f21248ab4835cd),4200000,62,441,

我在Robo 3T中查找了出售的物品,似乎有疑问的价值

{
    "_id" : ObjectId("5beca66f78f21248ab48354d"),
    "location" : {
        "address" : {
            "streetAddress" : "Sparbanksvägen 68"
        },
        "position" : {
            "latitude" : 59.29407363,
            "longitude" : 17.98445821
        },
        "namedAreas" : [ 
            "Hägersten"
        ],
        "region" : {
            "municipalityName" : "Stockholm",
            "countyName" : "Stockholms län"
        },
        "distance" : {
            "ocean" : 5907
        }
    },
    "rent" : 3179,
    "floor" : 2,
    "livingArea" : 42,
    "source" : {
        "name" : "Mäklarhuset",
        "id" : 204,
        "type" : "Broker",
        "url" : "http://www.maklarhuset.se/"
    },
    "rooms" : 2,
    "published" : ISODate("2017-10-13T09:12:35.000Z"),
    "constructionYear" : 1945,
    "objectType" : "Lägenhet",
    "booliId" : 3016715,
    "soldDate" : ISODate("2017-11-17T00:00:00.000Z"),
    "soldPrice" : 2600000,
    "soldPriceSource" : "bid",
    "publishedDays" : 407,
    "soldDays" : 442,
    "daysUp" : 35,
    "street" : "Sparbanksvägen Hägersten",
    "streetYear" : "Sparbanksvägen Hägersten 1945",
    "yearDay" : 321,
    "yearWeek" : 46
}

1 个答案:

答案 0 :(得分:1)

// @route POST api/users/register // @desc Register user // @access Public router.post('/register', (req, res)=>{ //Validate req.body const {errors, isValid} = validateRegisterInput(req.body); //Check validation if(!isValid){ return res.status(400).json(errors);  } User.findOne({ email: req.body.email }) .then(user => { if(user){ errors.email = 'Email already exists'; return res.status(400).json(errors) } else { const avatar = gravatar.url(req.body.email, { s: '200', //Size r: 'pg', //Rating d: 'mm' //Default }); const newUser = new User({ name: req.body.name, email: req.body.email, avatar, password: req.body.password }); //Hash the password and save bcrypt.genSalt(10, (err, salt)=>{ bcrypt.hash(newUser.password, salt, (err, hash)=>{ if(err) throw err; newUser.password = hash; newUser.save() .then(user => res.json(user)) .catch(err => console.log(err)) }) }); //Fill user categories with default categories defaultIcons.map((icon) => { const newCategory = new Category ({ name: icon.name, type: icon.type, icon: icon.icon }) newCategory.save(); }); } }) }); -您粘贴的文档没有 //Create Schema const CategorySchema = new Schema({ //Every account is associated with actual User schema by id user: { type: Schema.Types.ObjectId, ref: 'users' }, name: { type: String, required: true }, type: { type: String, required: true }, icon: { type: String, required: true } })