I am trying out Cloud Firestore. I think I have done something silly, so I am not able to even to create any docs/collection, both through code and through console.
I haven't locked the DB with any write/read rules (any one can read/write) to the DB. Below is my rule configuration.
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
When I try through console, it opens up a modal where I enter the collection name and the first document (using generated ID). Then clicking on 'Save' simply closes the modal, but the DB is not updated.
When I try to insert docs through code (JS), I could see the following error thrown on the console.
Error updating data: Error: PERMISSION_DENIED: Permission denied
at firebase-storage.js:3479
at z (firebase-storage.js:3479)
at t.callOnCompleteCallback (firebase-storage.js:3479)
at firebase-storage.js:3479
at firebase-storage.js:3479
at e.ci (firebase-storage.js:3479)
at t.ci (firebase-storage.js:3479)
at t.qi (firebase-storage.js:3479)
at e.onMessage (firebase-storage.js:3479)
at e._o (firebase-storage.js:3479)
Below is the JS code.
var config = {
apiKey: "xxxx",
authDomain: "xxxx.firebaseapp.com",
databaseURL: "https://xxxx.firebaseio.com",
projectId: "xxxx",
storageBucket: "",
messagingSenderId: "yyyy"
};
firebase.initializeApp(config);
var db = firebase.firestore();
$scope.addNote = function() {
var note = {
text: 'Sample Note',
createdBy: 'Ranis'
}
db.collection('notes').add(note).then(function(data) {
console.log('Note Added ', data)
},
function(err) {
console.log('Note Add Error ', err);
});
}