Ad
Where And When To Use Firebase Admin.app().delete()?
I'm new to using firebase and node.js and have a general question on where and when to use ' admin.app().delete() ' ?
I understand it's used to terminate access to the firebase app, but not sure I understand if you have to delete after every time you read/write to the realtime db? For example, in the code below should admin.app().delete() be used anywhere? And if it is used, will the app be initialized each time an export function (myFunc) in index.js is called?
\\index.js
admin.initializeApp(config.FIREBASE_CONFIG);
const foo = require('./foo');
exports.myFunc = functions.https.onRequest((req, res) => {
foo.readFunction().then().catch();
res.send('success!');
}
\\foo.js
exports.readFunction = function () {
const dbRef = admin.database().ref('/someCategory');
var infoPromise = dbRef.once('value').then((snapshot) => {
var info = snapshot.child('moreInfo').val();
return info;
}).catch((error) => {
console.log('file read failed: ' + errorObject.code);
throw error;
});
return infoPromise;
}
Ad
Answer
It doesn't make much sense to call App.delete()
from within a Cloud Function. Cloud Functions are aggressively terminated and cleaned up by the underlying platform anyway. App.delete()
is mainly useful in standalone applications and scripts to ensure graceful exit of the program.
Ad
source: stackoverflow.com
Related Questions
- → Maximum call stack exceeded when instantiating class inside of a module
- → Browserify api: how to pass advanced option to script
- → Node.js Passing object from server.js to external modules?
- → gulp-rename makes copies, but does not replace
- → requiring RX.js in node.js
- → Remove an ObjectId from an array of objectId
- → Can not connect to Redis
- → React: How to publish page on server using React-starter-kit
- → Express - better pattern for passing data between middleware functions
- → Can't get plotly + node.js to stream data coming through POST requests
- → IsGenerator implementation
- → Async/Await not waiting
- → (Socket.io on nodejs) Updating div with mysql data stops without showing error
Ad