如何autocomplete在主要浏览器中禁用特定input(或form field)?
我想运行以下查询:
Group.find({program: {$in: [...]}}).lean().select('_id')
Run Code Online (Sandbox Code Playgroud)
然后不要回复:
[{_id: ...}, {_id: ...}, {_id: ...}, {_id: ...}]
Run Code Online (Sandbox Code Playgroud)
但是:
[..., ..., ..., ...] where ... represents an _id of a Group
Run Code Online (Sandbox Code Playgroud)
当然我可以运行查询,然后遍历我回来的组,但我想在查询中尽可能这样做,因为这可能会更快.
感谢你们!
我想要做的是进入新标签或新窗口:
$state.go('studentsReport', {
type: $scope.report.type, // string
selectedStudents: $scope.selectedStudents // array of strings
});
Run Code Online (Sandbox Code Playgroud)
如果我做了:
var link = $state.href('studentsReport', {
type: $scope.report.type,
selectedStudents: $scope.selectedStudents
});
window.open(link, '_blank');`
Run Code Online (Sandbox Code Playgroud)
我会失去参数.
最好的问候,马塞尔
我想我的排序Group由-模型name的departure_country与猫鼬,PAGINATE和的NodeJS.
我的小组 - 架构:
var GroupSchema = new Schema({
name: String,
flight_date: Date,
....
departure_country: {type: Schema.ObjectId, ref: 'Country'},
....
});
Run Code Online (Sandbox Code Playgroud)
在乡村架构:
var CountrySchema = new Schema({
name: String,
code: String,
});
Run Code Online (Sandbox Code Playgroud)
使用国家的sortBymongoose-paginate排序 - _ids我不知道如何告诉它按照排序name.
每次函数对数据库进行更改时,我都希望使用nodeJS来刷新我的视图.如果我们以MEAN-stack为例,我不想每隔x秒发送一次$ http请求来检查是否对数据库进行了更改.我希望前端自动得到通知,然后更新视图.
这是什么最佳做法?我会在服务器端使用某种Oberserver模式,但不知道如何通过它来通知前端.
我有两个看起来几乎相同的函数,并且作为来自JavaScript函数的AJAX请求一个接一个地调用.
/**
* get all Airports for autocomplete
*/
public function getAirports(){
if(Cache::has('airports')){
return Cache::get('airports');
}
$airportModel = new Airport;
$airports = json_encode($airportModel -> _getForAutocomplete('iata_faa_code'));
Cache::put('airports', $airports, 600);
return $airports;
}
/**
* get all Countries for autocomplete
*/
public function getCountries(){
if(Cache::has('countries')){
return Cache::get('countries');
}
$countryModel = new Country;
$countries = json_encode($countryModel -> _getForAutocomplete('two_letter_code'));
Cache::put('countries', $countries, 600);
return $countries;
}
Run Code Online (Sandbox Code Playgroud)
现在,当我第一次访问该页面时,我正确地获取了数据(因为它还没有被缓存).如果我第二次访问该页面,我会收到这些国家/地区,但是对于机场我会遇到错误并且看不清楚原因.
{"error":{"type":"Illuminate\\Encryption\\DecryptException","message":"Invalid data.","file":"C:\\xampp\\htdocs\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Encryption\\Encrypter.php","line":132}}
我发现,它必须通过谷歌缓存和删除缓存部分做一些事情.如果有人可以帮我解决那个问题,我会很高兴的.
顺便说一句,我使用数据库作为我的缓存驱动程序.
最好的问候,马塞尔
我有一个地址,我想看看它是否已经在数据库中,如果没有,请创建一个新地址。我知道我可以findOrCreate()在这里使用,但让我们简单一点,检查一下为什么我什至找不到现有地址。
var address = {
name: req.body.name,
address1: req.body.address1,
address2: req.body.address2,
zip: req.body.zip,
city: req.body.city,
country: req.body.country,
user_id: req.body.user_id
};
Address.find({where: address}).then(function(result){
console.log(result);
}).catch(function(err){
console.error(err);
});
Run Code Online (Sandbox Code Playgroud)
生成的查询询问哪... AND user_id = NULL一个是错误的。应该问一下... AND user_id IS NULL。我怎样才能让sequelize为我做正确的事情?谢谢。
我想检查$ model是否是A,B或C类的实例,但不是D.所以我有一个这样的数组:
$relevant_classes = [A, B, C];
我知道我可以查看instance of模型是否在这些类的实例中.但是,如果模型是它的一个实例,我现在必须循环遍历数组并询问每个单独的类吗?
我宁愿做if(in_array($model, $relevant_classes))比较类实例的事情.这可能在PHP(Laravel)?
node.js ×3
laravel ×2
mongodb ×2
mongoose ×2
angularjs ×1
autocomplete ×1
browser ×1
caching ×1
html ×1
javascript ×1
mean-stack ×1
mysql ×1
pagination ×1
php ×1
sequelize.js ×1