小编Tri*_*ian的帖子

无效的架构配置:`model` 不是数组 `characters` 中的有效类型

我正在尝试创建一个架构子文档,但出现上面列出的错误,有问题的架构看起来像这个 Schema cassuing issues

const mongoose = require('mongoose');
const Schema = mongoose.Schema

const CharacterSchema = new Schema();
CharacterSchema.add({
    name: {
        type: String,
        required: true
    },
    title: {
        type: String
    },
    charcterClass: { // will be limited in form creation
        type: String
    },
    level: {
        type: Number
    }
});

const Charcter = mongoose.model('User', CharacterSchema);
module.exports = Charcter;
Run Code Online (Sandbox Code Playgroud)

架构调用架构上面

const mongoose = require ('mongoose');
const Schema = mongoose.Schema;
const {CharacterSchema} = require(__dirname +'/CharacterModel.js');

const UserSchema = new Schema()
UserSchema.add({
    name: {
        type: …
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb node.js

4
推荐指数
2
解决办法
6823
查看次数

不能将char转换为int?

我无法将 a 转换char为 an int,我不知道为什么。

我只是想将从 CSV 解析的一些数据转换stringint,编译器不会让我转换。

我收到此错误:

从类型 '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> > >::value_type {aka std::__cxx11::basic_string<char>}' 到类型 'int' 的无效转换

注意我也试过:

static_cast<int>(data[2]);
Run Code Online (Sandbox Code Playgroud)

乃至

'a' - data[2];
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?我觉得我已经做了一百万次了。

time_t startDate;
string ID;
int beds;
int numDays;
string token;
vector<string> data;

for(int i = 0; i < 2; i++){ // run through the rest of the file
    getline(customers, line);
    stringstream s(line); // to parse the csv

    while(getline(s,token, ',')){
        data.push_back(token);
    }

    startDate = changeToInt(data[0]);
    ID = data[1];
    ---> …
Run Code Online (Sandbox Code Playgroud)

c++ string vector stringstream

-1
推荐指数
1
解决办法
71
查看次数

标签 统计

c++ ×1

mongodb ×1

mongoose ×1

node.js ×1

string ×1

stringstream ×1

vector ×1