我的问题是我的表没有为我的字段“Distribuidora”更新,但其余字段更新完美。这是我的代码,也许我在数据库中失败了,但我都试过了
我的分销商 Mongodb 代码是:
takingstats.find({ distributor: distributorAux }, { projection: {
_id: 0 } }).sort({ rank: -1 }).toArray((err, takingArray) => {
if(takingArray.length>=1){
return res.send(takingArray);
}if(takingArray.lenght==1){
return res.send(takingArray[0]);
}else{
return res.sendStatus(404);
}
});
我的 JS/Angular 代码:
$scope.busqueda = function() {
$http.get(API + "?" + $scope.valor + "=" +
$scope.valor2).then(function(response) {
if(response.data.length>1){
$scope.takingstats = response.data;
console.log("Data received: " +
JSON.stringify(response.data, null, 2));
}else{
$scope.takingstats = [response.data];
console.log("Data received: " +
JSON.stringify(response.data, null, 2));
}
}).catch(function(response) {
if (response.status == 404) {
alert("Película no encontradas para dichos " +
$scope.valor);
};
$scope.estado = response.status;
});;
};
返回数据但表不更新
最佳答案
这是为我工作的解决方案,当我有一个对象将其转换为一个元素的数组时。如果有人需要我在这里写解决方案
$scope.busqueda = function() {
$http.get(API + "?" + $scope.valor + "=" + $scope.valor2).then(function(response) {
if(response.data.length>1){
$scope.takingstats = response.data;
console.log("Data received: " + JSON.stringify(response.data, null, 2));
}else{
//here is the new statement for transf object to array
$scope.takingstats = [response.data];
console.log("Data received: " + JSON.stringify(response.data, null, 2));
}
}).catch(function(response) {
if (response.status == 404) {
alert("Película no encontradas para dichos " + $scope.valor);
};
$scope.estado = response.status;
});;
};
关于javascript - 当我将数据放在 "distribuidora"字段时,我的表没有更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55870423/
我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我好像记得Lua有类似Ruby的method_missing的东西。还是我记错了? 最佳答案 表的metatable的__index和__newindex可以用于与Ruby的method_missing相同的效果。 关于ruby-难道Lua没有和Ruby的method_missing相媲美的东西吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/7732154/
为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar
我有一个奇怪的问题:我在rvm上安装了rubyonrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(
我有一个表单,其中有很多字段取自数组(而不是模型或对象)。我如何验证这些字段的存在?solve_problem_pathdo|f|%>... 最佳答案 创建一个简单的类来包装请求参数并使用ActiveModel::Validations。#definedsomewhere,atthesimplest:require'ostruct'classSolvetrue#youcouldevencheckthesolutionwithavalidatorvalidatedoerrors.add(:base,"WRONG!!!")unlesss
我想向我的Controller传递一个参数,它是一个简单的复选框,但我不知道如何在模型的form_for中引入它,这是我的观点:{:id=>'go_finance'}do|f|%>Transferirde:para:Entrada:"input",:placeholder=>"Quantofoiganho?"%>Saída:"output",:placeholder=>"Quantofoigasto?"%>Nota:我想做一个额外的复选框,但我该怎么做,模型中没有一个对象,而是一个要检查的对象,以便在Controller中创建一个ifelse,如果没有检查,请帮助我,非常感谢,谢谢
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re