MCPcopy Index your code
hub / github.com/NativeScript/firebase / init

Method init

apps/demo/src/plugin-demos/firebase-firestore.ts:74–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72 }
73
74 async init() {
75 firebase()
76 .firestore()
77 .collection('users')
78 .add({
79 first: 'Ada',
80 last: 'Lovelace',
81 born: 1815,
82 })
83 .then((docRef) => {
84 console.log('Document written with ID: ', docRef.id);
85 })
86 .catch((error) => {
87 console.error('Error adding document: ', error);
88 });
89
90 const geo = new GeoPoint(10, -10);
91 firebase()
92 .firestore()
93 .collection('geo')
94 .add({
95 thing: 'it',
96 geo,
97 })
98 .then((docRef) => {
99 console.log('Geo Document written with ID: ', docRef.id);
100 })
101 .catch((error) => {
102 console.error('Error adding geo document: ', error);
103 });
104
105 firebase()
106 .firestore()
107 .collection('items')
108 .get()
109 .then((items) => {
110 console.log(items.docs[0].data());
111 });
112
113 const exampleDoc = firebase().firestore().collection('things').doc('exampleDoc');
114 const exampleDoc2 = firebase().firestore().collection('things').doc('exampleDoc2');
115
116 firebase()
117 .firestore()
118 .batch()
119 .set(exampleDoc, {
120 message: 'Hello doc',
121 })
122 .set(exampleDoc2, {
123 date: new Date(),
124 })
125 .commit()
126 .then(() => {})
127 .catch((error) => {
128 console.error(error);
129 });
130 }
131

Callers 3

webpack.config.jsFile · 0.45
webpack.config.jsFile · 0.45
webpack.config.jsFile · 0.45

Calls 13

firebaseFunction · 0.90
addMethod · 0.65
collectionMethod · 0.65
firestoreMethod · 0.65
logMethod · 0.65
getMethod · 0.65
dataMethod · 0.65
docMethod · 0.65
commitMethod · 0.65
setMethod · 0.65
batchMethod · 0.65
thenMethod · 0.45

Tested by

no test coverage detected