简体   繁体   中英

Creating clean Vapor project (using fluent) results in MongoKitten runtime error

I managed to setup Vapor with MongoDB and get it working but if I do a new clean project I get runtime error from MongoKitten. In detail:

I have an outdated vapor project that works fine from 27/07/2017. I do the same exactly project now 24/10/2017. When it compiles for the first time I get the following warning (don't know if is relevant to the following error):

警告截图

Compilation finishes and I get the following error when I run the project:

错误截图

I only know that this is caused by the preparation step in main.swift eg here:

config.preparations.append(User.self)

Without this step I dont get any runtime error (but fluent connection to mongodb isn't working properly either).

My config is pretty simple:

配置截图

This happens in Swift 3.1.1 but same happens in Swift 4.0. Environment is Ubuntu 17.04.

How can I solve this?

MongoDB's $addFields stage requires MongoDB 3.4 or greater (we're almost at 3.6, so 3.4 is the latest release). I'm assuming you're running MongoDB 3.2 or lower. Ubuntu's official APT repository is and has been behind the official MongoDB releases for a long time. Some ubuntu versions will still install the deprecated 2.6 release of MongoDB.

The solution is to install the official latest MongoDB server as described here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM