Node.js Azure Easy API-找不到getTable('tableName')的文档。插入
我正在我的应用程序服务上使用Azure Easy API。我正在做一点实验,但是我找不到合适的文档 当我制作一个新的Easy API时,上面的评论说 //使用request.service访问移动服务的功能,例如: //var tables=request.service.tables 所以我从那里开始发现我可以使用request.service.tables.getTable'tableName.insert{columnName:value}添加到我的任何表中 我期待。插入以返回承诺,但它没有。事实上,它似乎根本没有返回任何东西。但我认为它是异步的 由于它不返回承诺,我的下一个赌注是它接受回调,但当我尝试.insert{columnName:value},functor{response.sendr.toString}时,整个api根本无法工作 我应该如何使用这个.insert函数 我在哪里可以找到自己学习这些信息的文档?谷歌搜索毫无用处。这是一个可以在Easy API中用于向表中插入记录的方法Node.js Azure Easy API-找不到getTable('tableName')的文档。插入,node.js,azure,azure-web-app-service,Node.js,Azure,Azure Web App Service,我正在我的应用程序服务上使用Azure Easy API。我正在做一点实验,但是我找不到合适的文档 当我制作一个新的Easy API时,上面的评论说 //使用request.service访问移动服务的功能,例如: //var tables=request.service.tables 所以我从那里开始发现我可以使用request.service.tables.getTable'tableName.insert{columnName:value}添加到我的任何表中 我期待。插入以返回承诺,但它没
module.exports = {
"get": function (req, res, next) {
req.azureMobile.tables('tableName')
.insert({columnName: 'value'})
.then(() => res.status(201).send('Success!'))
.catch(next);
}
}
app.js文件将包含以下内容
// ----------------------------------------------------------------------------
// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
// ----------------------------------------------------------------------------
// This is a base-level Azure Mobile App SDK.
var express = require('express'),
azureMobileApps = require('azure-mobile-apps');
// Set up a standard Express app
var app = express();
// If you are producing a combined Web + Mobile app, then you should handle
// anything like logging, registering middleware, etc. here
// Configuration of the Azure Mobile Apps can be done via an object, the
// environment or an auxiliary file. For more information, see
// http://azure.github.io/azure-mobile-apps-node/global.html#configuration
var mobileApp = azureMobileApps({
// Explicitly enable the Azure Mobile Apps home page
homePage: true,
// Explicitly enable swagger support. UI support is enabled by
// installing the swagger-ui npm module.
swagger: true
});
// Import the files from the tables directory to configure the /tables endpoint
mobileApp.tables.import('./tables');
// Import the files from the api directory to configure the /api endpoint
mobileApp.api.import('./api');
// Initialize the database before listening for incoming requests
// The tables.initialize() method does the initialization asynchronously
// and returns a Promise.
mobileApp.tables.initialize()
.then(function () {
app.use(mobileApp); // Register the Azure Mobile Apps middleware
app.listen(process.env.PORT || 3000); // Listen for requests
});
下面的答案包含。那么,这意味着这确实返回了一个承诺。当您测试代码时,它会返回什么?尽管我不是JS专家,但您现有的代码似乎并不包含捕获承诺的代码。当您尝试使用回调时,您得到了什么错误?下面的答案确实包含。然后,但它调用了不同的函数。我使用request.service.tables.getTable,而他使用request.azureMobile.tables。当我测试代码时,我很自然地就有了一个。然后在我插入之后,在日志中它说了一些类似的东西。然后不存在于undefined上——显然不是逐字逐句,类似的东西。我能够确定。事实上,insert返回未定义或null或类似的内容。只是说。。。。完整的代码示例和完整的错误消息使这些问题更容易解决。i、 一个完整的复制品。虽然我不太可能自己解决这个问题,但其他人可能会谢谢你,我会很快尝试这个方法,如果我成功的话,我会把你的答案标记为正确的。没用。可能是因为我在较旧版本的Azure上提供了此应用程序服务。我检查了app.js文件,不需要“azure-mobile-apps”;,只需要“azure-mobile-services”;没关系,反正我的api是通过SQL运行的,我想这已经足够好了。谢谢azure移动服务似乎已被弃用,但我不确定“迁移”的可行性。人力资源管理…请不要标记为正确,如果它实际上不工作!