我试过寻找一个答案,但似乎无法让这个工作.我正在使用Meteor与Cordova构建移动应用程序.
我想为我的Users集合添加一个属性(Meteor在我登录时创建的属性).即.例如,我想将{currentHotel:"Something"}添加到我的db.Users集合中.
我正在尝试以正确的Publish - Subscribe方式执行此操作.使用Meteor.methods被引用对实时应用程序不利.无论哪种方式,我想了解如何使用Publish - Subscribe更新Users集合.
//On the server, I did
Meteor.publish("userData", function () {
return Meteor.users.find({_id: this.userId},
{fields:{services: 1, currentHotel: 1}});
});
Run Code Online (Sandbox Code Playgroud)
因此,客户端应该可以访问currentHotel字段.现在更新"currentHotel"字段:
//On the client I do
Meteor.subscribe('userData');
var user = Meteor.users.findOne({"_id": Meteor.userId()});
Meteor.users.update({_id: user._id}, {$set:{currentHotel:'something'}});
//I tried this too
//Meteor.users.update({ _id: Meteor.userId() }, {$set: });
Run Code Online (Sandbox Code Playgroud)
在浏览器控制台上,我可以看到"currentHotel"和"services"就好了,这意味着发布 - 订阅工作正常.但我似乎无法更新currentHotel.我得到一个拒绝访问.为什么是这样?
此外,如果Collection中根本不存在"currentHotel"属性,我如何使用类似的发布 - 订阅添加它?我是否可以发布不存在的属性并允许客户订阅并添加该属性?
我提到了Meteor文档,这个,这个和这个,但似乎仍然无法让它工作!:-(
提前致谢!
collections publish-subscribe mongodb meteor meteor-accounts
嘿大家刚刚开发了我的第一个登录到Facebook的Android应用程序并尝试状态更新没有对话框,使用图形API.下面的代码是授权代码(它位于fbook开发站点本身),它一直对我很好,直到最近.现在我的应用程序在我的模拟器上正常登录,但当我导出APK文件并将其放在我的手机上时,它会给我"身份验证错误".有人可以解释一下吗?它只是不再向我显示登录页面,在我创建之后一个新的密钥库和hashkey并像往常一样在facebook上的我的开发应用页面上更新了这个hashkey.
我认为这是由于keyhash等,但我不明白这一点,以找出错误.我做的是,我点击导出,应用程序,然后我创建一个新的密钥库(第一次,否则我使用现有的密钥库),然后我发现我的哈希键使用"keytool exportcert"等在fbook开发站点上显示.然后我在我的Facebook帐户中输入该哈希键到应用程序中.但有时即使密钥库密码是正确的,它说"密钥库格式"也不同,即使我在同一个应用程序之前使用它!然后我必须创建一个新的密钥库,再次exportcert,这一切都很痛苦!必须有一个更简单的方法吗?
有人可以解释Facebook应用程序的哈希键是如何工作的吗?
提前致谢!
我的验证码:
public void login()
{
facebook.authorize(this,new String[] { "email", "read_stream", "publish_stream"}, new DialogListener(){
int fbcheck=0;
@Override
public void onComplete(Bundle values) {
fbcheck=1;
facebookauthcheck(fbcheck);
}
@Override
public void onFacebookError(FacebookError error) {
fbcheck=0;
facebookauthcheck(fbcheck);
}
@Override
public void onError(DialogError e) {
fbcheck=0;
facebookauthcheck(fbcheck);
}
@Override
public void onCancel() {
fbcheck=2;
facebookauthcheck(fbcheck);
}
});
}
public void facebookauthcheck(int fbcheck)
{
if (fbcheck == 0) {
Toast.makeText(this, "Authentication Error", Toast.LENGTH_LONG).show();
}
else if (fbcheck==1)
{
Toast.makeText(this, "Authenticated", Toast.LENGTH_LONG).show();
} …Run Code Online (Sandbox Code Playgroud) 所以我正在从Kathy Sierra的书中学习SCJP.在字符串一章中,这是一个问题:
String s1 = "spring ";
String s2 = s1 + "summer ";
s1.concat( "fall ");
s2.concat(s1);
s1 += "winter";
System.out.println(s1+" "+s2);
---------------------------
What's the output, and how many string objects and ref variables are created?
Run Code Online (Sandbox Code Playgroud)
输出是春冬春夏,有两个参考变量,没关系.
然后它说创建了八个字符串对象(春天,夏天,春天......等)包括由于没有引用它们而丢失的那些.
但是,它不包括最后一个sysout中的任何内容.
我的问题是,在最后一行代码中,由于s1和s2正在与空格连接,这是否也会创建新对象?或者它只是传递给字符串缓冲区进行显示,而不是创建新对象?
这显然是非常基本的,我看了别处,但没有直接回答这个问题.根据我的理解,它也应该在那里创建新的对象,但我需要确保参加考试!思考?
提前致谢!
我已经写了一堆代码,对支出金额(有效条目32.4554,234,324.34等等).我还编写了代码来限制用户输入超过13位数(不包括.和,).
所有这些在Firefox中完美运行.但是在IE 8中,在数字位数超过13之后,如果输入了一个字母,Internet Explorer就会挂起并崩溃!调试时我注意到它在正则表达式线上出错,但同样的正则表达式工作正常,直到没有超过13的限制!Regexperts,拜托!给我看灯!
function isIncorrectSpend(cubeCurrencySpend) {
if(!(/^([1-9]*[0-9]*,?[0-9]*)* (\.[0-9]*)?$/.test(cubeCurrencySpend))) {
return true;
}
return false;
}
function isLongerThanThirteenDigits(cubeCurrencySpend) {
cubeCurrencySpend = cubeCurrencySpend.replace(/,/g, "").replace(/\./g, "");
if(cubeCurrencySpend.length>12) {
return true;
}
return false;
}
jQuery("input#minval").keyup( function() {
if(isIncorrectSpend(jQuery("input#minval").val())) {
jQuery("input#minval").val("");
alert("please enter correct spend value");
}
});
jQuery("input#minval").keypress( function(e) {
var code = (e.keyCode ? e.keyCode : e.which);
if(isLongerThanThirteenDigits(jQuery("input#minval").val()) && (code > 47 && code < 58)) {
alert("Please enter a number less than …Run Code Online (Sandbox Code Playgroud) android ×1
collections ×1
facebook ×1
immutability ×1
java ×1
jquery ×1
meteor ×1
mongodb ×1
regex ×1
scjp ×1
string ×1
system.out ×1