考虑以下简单的onCreate触发器功能。
exports.sampleFunction = functions.database.ref('/foo/{recordID}')
.onCreate(event => {
console.log(event);
});
我使用firebase experimental:functions:shell
在本地调用函数以使用以下命令进行测试:
sampleFunction('/TEST-DATA/', {params: {recordID: "Test Param Value"}});
我收到以下输出,请注意event.params
为空。
info: { eventId: '4282b14f-edea-4497-8bee-b045023b0a84',
timestamp: '2017-10-15T16:12:59.812Z',
data:
DeltaSnapshot {
app:
FirebaseApp {
firebaseInternals_: [Object],
services_: [Object],
isDeleted_: false,
name_: '__admin__',
options_: [Object],
database: [Function: bound ],
auth: [Function: bound ],
messaging: [Function: bound ],
INTERNAL: [Object] },
adminApp:
FirebaseApp {
firebaseInternals_: [Object],
services_: [Object],
isDeleted_: false,
name_: '__admin__',
options_: [Object],
database: [Function: bound ],
auth: [Function: bound ],
messaging: [Function: bound ],
INTERNAL: [Object] },
_path: '/foo/Test Param Value',
_data: null,
_delta: '/TEST-DATA/',
_newData: '/TEST-DATA/' },
eventType: 'providers/google.firebase.database/eventTypes/ref.create',
resource: 'projects/_/instances/silk-39c1f/refs/foo/Test Param Value',
auth: { admin: true },
params: {} }
info: Execution took 10 ms, user function completed successfully