小编J.D*_*Doe的帖子

Firestore-检查用户名是否已存在

我需要 Firestore 方面的帮助。我有一个 AllUsers 数据集合,其中包含每个用户信息的用户 ID 文档。我想检查用户名是否已经存在;//“该用户名已经存在”。我该怎么做?

` setupBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            final String user_name = setupName.getText().toString();

            Map<String, Object> commentsMap = new HashMap<>();
            commentsMap.put("user_id", user_id);
            commentsMap.put("timestamp", FieldValue.serverTimestamp());
            commentsMap.put("user_name",user_name);
            firebaseFirestore.collection("AllUsers").document(user_id).set(commentsMap).addOnCompleteListener(new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    if(task.isSuccessful()){
                        Intent asda=new Intent(getApplicationContext(),MainActivity.class);
                        startActivity(asda);
                        finish();
                   }

                }
            });
Run Code Online (Sandbox Code Playgroud)

`

java android firebase google-cloud-firestore

3
推荐指数
1
解决办法
6742
查看次数

如何更新子集合Firestore?

我想更新子集合的所有文档。示例:传感器/用户 ID/数据 我想更新所有成员。是否可以?

android firebase google-cloud-firestore

2
推荐指数
1
解决办法
7574
查看次数

标签 统计

android ×2

firebase ×2

google-cloud-firestore ×2

java ×1