npm i sky-firestore
In your JavaScript file:
var initFirebase = require("sky-firestore").initFirebase
var createMap = require("sky-firestore").createMap
Create your own Firebase project and get your credentials:
- Go to firebase console.
- Settings
- General
- Click on the web icon (</>)
- copy the config object.
var config = {
apiKey: "YOUR_KEY",
authDomain: "YOUR_DOMAIN",
databaseURL: "YOUR_URL",
projectId: "YOUR_PROJECTURL",
storageBucket: "YOUR_BUCKET",
messagingSenderId: "YOUR_ID"
};
Initiate your firebase project by passing your configuration object to the initFirebase()
function:
initFirebase(config);
CreateMap()
Creats a collection with a document inside that has a map (key-value paired object) inside.
var obj= {
name: John,
lastName: Doe,
dob: "1/1/2001"
}
createMap("collectionName", "documentName", "mapName", obj)
Firebase Data Structuring Rules:
- Documents have limits:
- 1 mb of data per document
- Can't have more than ~20,000 fields (nested fields count as well)
- 1 write per second (avoid having multiple users write in one document)
- Cant retrieve a partial document:
- entire document is downloaded when called from a client sdk (another reason to keep the documents small)
- queries are shallow:
- subcollections aren't retrieved.
- queries find documents in a single collection.
- You are billed per reads