我希望我的REST API端点使用模型的所有小写字母.
在内置的情况下User的模式,我会简单地做了一个名为新模式user与User作为基准?或者我应该使用另一种方法吗?
我有一个用户模型和一个跟随者模型,它跟随用户和跟随者的用户具有HasManyThrough关系.如何更改默认的__get__followers方法参数?
我正在寻找可以从Android调用loopback的自定义方法的示例.为了解释更多,假设我在服务器端有一个名为"greet(name)"的方法,它将迎接某人.我想从Android调用它.任何例子,或链接都可以.
提前致谢.
Jahid
我改编自Ray Wenderlich的iOS Apprentice教程第4部分。
这段代码可以作为GET请求发送到带有简单数据库模型的Strongloop API,但是:
这行得通,但我不知道为什么行得通,因为它没有调用我可以看到的实际发送请求的方法。
我认为没有任何方法可以使其进入POST请求。
我的问题是:如何执行POST请求?以完全不同的方式完成吗?
如果您需要更多信息,请与我们联系。
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func getFromDB() {
let url = urlWithSearchText("")
println("URL: '\(url)'")
if let jsonString = performGetRequestWithURL(url) {
println("Received JSON string '\(jsonString)'")
}
}
func urlWithSearchText(searchText: String) -> NSURL {
let escapedSearchText = searchText.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
let …Run Code Online (Sandbox Code Playgroud) 尝试使用server.js中的代码从模型创建表:
app.datasources['Billing'].automigrate(['Roles', 'Users'], function(err) {
console.log(err);
});
Run Code Online (Sandbox Code Playgroud)
并得到以下错误:
[Error: Cannot migrate models not attached to this datasource: Roles Users ]
Run Code Online (Sandbox Code Playgroud)
实际上我不确定节点如何在mysql db中创建表,但是这个解决方案是在手册中提供的.
可能有人链接到有关此问题的良好文档.
我有一个有趣的问题.我正在尝试通过上传表单
<form enctype="multipart/form-data" action="/myendpoint/:id">
<input type="hidden" name="data" value="mydata" />
<input type="file" name="formname" />
</form>
Run Code Online (Sandbox Code Playgroud)
...和我的远程方法调用:
Patient.uploadVideo = function(id, mydata, cb) {
console.log(mydata);
return cb(null, { id: 123 });
};
MyModel.remoteMethod(
'uploadVideo',
{
http: {path: '/:id/recording/:recordingid/videos', verb: 'post'},
accepts: [
{arg: 'id', type: 'string', required: true},
{arg: 'mydata', type: 'object', 'http': {source: 'body'}},
]
}
);
Run Code Online (Sandbox Code Playgroud)
不幸的是身体是空白的
如何获取表单数据?我修改了server/datasources.json来包含
"storage": {
"name": "storage",
"connector": "loopback-component-storage",
"provider": "filesystem",
"root": "./server/storage"
}
Run Code Online (Sandbox Code Playgroud)
依然没有.
谢谢
我正在尝试在loopback.io中进行查询.但找不到与此相关的任何功能.这是我尝试过的:
Product.find({
where: {
name: {
like: '%' + searchTerm + '%'
},
id: {
neq: [1,2,3]
}
},
limit: 15
}, function(err, searchResults) {...}
Run Code Online (Sandbox Code Playgroud)
事实上,生成的查询是:
'SELECT `id`,`name`,`ref` FROM `Product` WHERE `name` LIKE \'%iPh%\' AND `id`!=1, 2, 3 ORDER BY `id` LIMIT 15' }
Run Code Online (Sandbox Code Playgroud)
我知道我们可以检查一下
field in (n1,n2,...)
Run Code Online (Sandbox Code Playgroud)
使用https://docs.strongloop.com/display/public/LB/Where+filter#Wherefilter-inq.但我不能得到'不在'的情况.
以前有人遇到过这种情况吗?
是否可以在由Strongloop Loopback中的资源管理器生成的swagger-ui中的方法中隐藏id属性?我不希望用户创建新资源并发送id属性.我知道如果用户发送id,它可以被忽略但我想在资源管理器中隐藏它.
我是环回的新手.我为所有用户创建了ACL拒绝权限($ everyone).但我可以通过swagger访问所有API.任何人都可以解释这个吗?以下是我的ACL.谢谢.
"acls": [
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY"
}
]
Run Code Online (Sandbox Code Playgroud) 'use strict';
module.exports = function (City) {
City.GetCurrentPopulation = function (req) {
var population;
City.app.models.Pupulation.find({where{id:req.id}}, //This line //gives me an error that cannot read property 'find' of undefined
function(req.res){
population=res.population;
});
response='Population for ' +req.cname ' is' +population;
req(null, response);
};
City.remoteMethod(
'GetCurrentPopulation', {
http: {
path: '/GetCurrentPopulation',
verb: 'GetCurrentPopulation'
},
returns: {
arg: 'startdate',
type: 'string'
}
}
);Run Code Online (Sandbox Code Playgroud)
有一个模型城市,我想访问另一个模型,如"population.find(一些过滤器)"如何做到这一点?
我有一个用城市模型编写的远程方法.我试图访问人口记录的地方
var countryp = population.find(其中{id:4});
var currentpopulation = countryp.Totalpopulation;
它给出了一个错误population.find不是一个函数.
请建议如何做到这一点.
strongloop ×10
loopbackjs ×8
node.js ×3
loopback ×2
acl ×1
android ×1
ios ×1
javascript ×1
post ×1
postgresql ×1
swagger ×1
swift ×1