-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
62 lines (54 loc) · 1.38 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const { GeoPoint, FieldValue } = require("@google-cloud/firestore");
const firestore = require("./Firestore");
const Model = require("./src/model/Model");
const Field = require("./src/fields/Field");
const BaseField = require("./src/fields/BaseField");
class Fireo {
static async runTransaction(callback) {
return await firestore.conn.runTransaction(async (t) => callback(t));
}
static batch() {
return firestore.conn.batch();
}
/**
* Create GeoPoint
* @param {number} latitude The latitude as a number between -90 and 90
* @param {number} longitude The longitude as a number between -180 and 180
*/
static GeoPoint(latitude, longitude) {
return new GeoPoint(latitude, longitude);
}
/**
* Add element in firestore list
* @param {Any} element - element to add in list
*/
static listUnion(element) {
return FieldValue.arrayUnion(element);
}
/**
* Remove element in firestore list
* @param {Any} element - element to remove in list
*/
static listRemove(element) {
return FieldValue.arrayRemove(element);
}
/**
* Increment number in firestore
* @param {number} number increment number
*/
static increment(number) {
return FieldValue.increment(number);
}
/**
* Get firestore connection
*/
static get connection() {
return firestore;
}
}
module.exports = {
Fireo,
Model,
Field,
BaseField,
};