Firestoreでidのわからないdocumentを取得したいときはどうすればいいのか
[Firebase]Getting all documents from one collection in Firestore
Getting all documents from one collection in Firestore
const events = await firebase.firestore().collection('users')
events.get().then((querySnapshot) => {
const tempDoc = []
querySnapshot.forEach((doc) => {
var data = doc.data();
console.log(data);
tempDoc.push(data);
})
console.log(tempDoc);
})
[Firebase]匿名認証サンプルコード
匿名認証サンプルコード
const firebaseConfig = {
apiKey: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
authDomain: "sample.firebaseapp.com",
databaseURL: "https://sample.firebaseio.com",
projectId: "sample",
storageBucket: "sample.appspot.com",
messagingSenderId: "XXXXXXXXX",
appId: "1:XXXXXXX:web:XXXXX"
};
const app = firebase.initializeApp(firebaseConfig);
await firebase.auth().signInAnonymously().catch(e => {
console.log(e)
})
[Firebase]auth/admin-restricted-operation This operation is restricted to administrators only.エラー対応
Firebaseで認証時に以下のエラーの対応
auth/admin-restricted-operation This operation is restricted to administrators only.
Firebaseのコンソール画面 > Authentication > Sign-in method > 利用したい認証方式有効
[Firebase]匿名認証
匿名認証
Authentication > Sign-in method > 匿名

> 有効にする > 保存

確認

[Salesforce]Apex コントローラでの内部クラスの使用
Apex コントローラでの内部クラスの使用
public with sharing class SampleController {
//Sample用
public SampleSetting Sample {get;set;}
// コンストラクタ
public SampleController(){
//初期処理
init();
}
//初期処理
private void init(){
//Sample
SampleSet();
}
//Sample
private void SampleSet(){
// カスタム[SampleSetting]から情報取得
SampleSetting__c mc = SampleSetting__c.getOrgDefaults();
mc = SampleSetting__c.getOrgDefaults();
this.Sample = new SampleSetting();
this.Sample.Sample_Key = mc.Sample_Key__c;
}
//Sampleクラス
public class SampleSetting {
public String Sample_Key {get;set;}
public SampleSetting(){
this.Sample_Key = '';
}
}
}
[Technical Method]JSONの整形
[JavaScript]JSON.stringify
JSON.stringify
var obj = {
a: 1,
b: "Moji",
c: [1, 2, 3, 4],
d: {
"A": 1,
"B": 2
}
};
console.log(JSON.stringify(obj));
結果
{"a":1,"b":"Moji","c":[1,2,3,4],"d":{"A":1,"B":2}}
[Technical Method]UNIX時間⇒日付変換
UNIX時間⇒日付変換
[JavaScript]Object.keys()
Object.keys()
const obj = {
name: '田中 太郎',
age: 30,
area: 'Tokyo'
}
const result = Object.keys(obj);
console.log(result);
結果
["name", "age", "area"]
Object.keys(obj).forEach(function(data) {
console.log(data);
})
結果
name
age
area