首页 > 解决方案 > Azure 移动应用 Nodejs 后端提供的数据类型无效

问题描述

我正在尝试在表中插入一行。这是我所做的步骤:

我在数据库中运行 Create table Statement 来创建表测试

    Create table test4
(
    id int primary key identity (1, 1),
    name nvarchar(100)
)

然后我转到应用服务编辑器并创建名为 test4.js 的文件 javascript

var table = module.exports = require('azure-mobile-apps').table();

然后我转到我的 API 并执行插入逻辑:

var test = {
            name: "test country1",

        };

    req.azureMobile.tables('test4')
        .insert(test)
        .then(() => res.send({
        status: config.get('statusResponse.success'),
        token: 'token'
    })).catch(error => {console.log("error " + error)});

我不知道为什么我得到这个错误。

error 错误:提供的数据类型无效

我更新我的问题

当我使用 Azure 的 Easy 表创建表时,我可以将记录插入表中,但我想使用我用 tsql 创建的存在表

标签: javascriptnode.jsazureazure-sql-databaseazure-mobile-services

解决方案


error 错误:提供的数据类型无效

根据您提供的创建表的语句:

Create table test4
(
    id int primary key identity (1, 1),
    name nvarchar(100)
)

作为ZUMO.V2(Azure 移动应用程序)的 30 天:第 6 天 - 个人表格提到了系统字段:

'id' 字段是一个字符串——它可以是任何东西,但它必须是唯一的,因为 id 是主键。如果未指定,Azure 移动应用会将 v4 GUID 的字符串表示形式分配给此字段。


推荐阅读