此代码有效:
firebase.database().ref($scope.language).orderByChild('word').equalTo($scope.word).once('value')
.then(function(snapshot) {
console.log(snapshot.val());
})
Run Code Online (Sandbox Code Playgroud)
它记录对象及其键。
此代码不起作用:
firebase.database().ref($scope.language).orderByChild('word').equalTo($scope.word).remove()
.then(function(snapshot) {
console.log("Removed!");
})
Run Code Online (Sandbox Code Playgroud)
错误信息是:
TypeError: firebase.database(...).ref(...).orderByChild(...).equalTo(...).remove is not a function
Run Code Online (Sandbox Code Playgroud)
该文档使remove()看起来很简单。我错过了什么?
在火力地堡SDK云功能迁移指南:测试版到1.0版文档中说,云计算功能的触发onUpdate参数现在(change, context)。如果我登录,change我会得到一个对象:
Change {
before:
QueryDocumentSnapshot {
_ref: DocumentReference { _firestore: [Object], _referencePath: [Object] },
_fieldsProto: { word: [Object] },
_readTime: undefined,
_createTime: '2018-04-10T15:37:11.775234000Z',
_updateTime: '2018-04-10T15:58:06.388975000Z' },
after:
QueryDocumentSnapshot {
_ref: DocumentReference { _firestore: [Object], _referencePath: [Object] },
_fieldsProto: { word: [Object] },
_readTime: undefined,
_createTime: '2018-04-10T15:37:11.775234000Z',
_updateTime: '2018-04-10T15:58:06.388975000Z' } }
Run Code Online (Sandbox Code Playgroud)
文档说我可以使用change.before.val()和从此对象获取数据change.after.val()。但记录change.before.val()导致此错误消息:
TypeError: change.before.val is not a function
Run Code Online (Sandbox Code Playgroud)
日志记录change.after.val()产生此错误消息:
TypeError: Cannot read property 'val' …Run Code Online (Sandbox Code Playgroud) javascript firebase google-cloud-functions google-cloud-firestore
听众在错误的时间触发问题。我试图查看元数据的变化:
firebase.firestore().collection('Users').doc($scope.user.uid).collection($scope.longLanguage).doc('Missing_Word').onSnapshot(function(snapshot) {
snapshot.docChanges().forEach(function(change) {
console.log(change.doc.data());
})
Run Code Online (Sandbox Code Playgroud)
这是错误消息:
Uncaught TypeError: snapshot.docChanges is not a function
Run Code Online (Sandbox Code Playgroud)
我也尝试打开metadataChanges:
firebase.firestore().collection('Users').doc($scope.user.uid).collection($scope.longLanguage).doc('Missing_Word').onSnapshot({includeMetadataChanges: true}, function(snapshot) {
snapshot.docChanges().forEach(function(change) {
console.log(change.doc.data());
})
Run Code Online (Sandbox Code Playgroud)
我们在文档附近写了这个。知道我们在做什么错吗?
IBM Watson Translate 正在与 配合使用curl,但我们无法让它与 Postman 配合使用。我们有一个apikey,但我不知道把它放在邮递员中的哪里。我查看了Authorization选项卡,没有看到任何接受 an 的选项apikey(选项包括Basic Auth、Digest Auth等)。我试着把我们的apikey 放进Params去Headers但我们总是回来401, Unauthorized。我们的apikey作品与curl.
浏览Firestore文档,我看到了许多示例,functions.firestore.document但我没有看到任何示例functions.firestore.collection.Firestore语法是
firebase.firestore().collection('...').doc('...')
Run Code Online (Sandbox Code Playgroud)
我收到一条错误消息
firebase.firestore().document('...')
Run Code Online (Sandbox Code Playgroud)
然而在使用此代码的云函数中:
exports.myFunction = functions.firestore.collection('...').doc('...').onUpdate(event => {
Run Code Online (Sandbox Code Playgroud)
在部署时我收到一条错误消息:
TypeError: functions.firestore.collection is not a function
Run Code Online (Sandbox Code Playgroud)
当我将代码更改为
exports.getWatsonTokenFirestore = functions.firestore.document('...').onUpdate(event => {
Run Code Online (Sandbox Code Playgroud)
我在部署时没有收到错误消息.
为什么云功能似乎具有与云Firestore不同的数据结构?
这是我的完整云功能.我的收藏是User_Login_Event,我的文件是Toggle_Value:
exports.getWatsonTokenFS = functions.firestore.document('User_Login_Event/{Toggle_Value}').onUpdate(event => {
var username = 'TDK',
password = 'swordfish',
url = 'https://' + username + ':' + password + '@stream.watsonplatform.net/authorization/api/v1/token?url=https://stream.watsonplatform.net/speech-to-text/api';
request({url: url}, function (error, response, body) {
admin.firestore().collection('IBM_Watson_Token').document('Token_Value').update('token');
});
return 0; // prevents an error message "Function returned undefined, expected Promise or value" …Run Code Online (Sandbox Code Playgroud) 我没有在应用程序中看到我的图像,而是看到一个带有 X 的红色框,上面写着Unable to load asset: images/aboutmaggie.png.
我创建了一个assets带有子目录的目录images。该目录assets与 处于同一级别pubspec.yaml。
我将图像放入images目录中。当我在 Android Studio 中单击图像时,图像就会显示。
在pubspec.yaml我有这些行:
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/images/
Run Code Online (Sandbox Code Playgroud)
我添加了
flutter:
# The following …Run Code Online (Sandbox Code Playgroud) 该谷歌云存储文件的download()建议,目标文件夹可以指定:
file.download({
destination: '/Users/me/Desktop/file-backup.txt'
}, function(err) {});
Run Code Online (Sandbox Code Playgroud)
无论我在文件中输入什么值,它都会在根级别下载到 Firebase Cloud Storage。这个问题说路径不能有初始斜杠但将示例更改为
file.download({
destination: 'Users/me/Desktop/file-backup.txt'
}, function(err) {});
Run Code Online (Sandbox Code Playgroud)
没什么区别。
将目的地更改为
file.download({
destination: ".child('Test_Folder')",
})
Run Code Online (Sandbox Code Playgroud)
导致错误消息:
EROFS: read-only file system, open '.child('Test_Folder')'
Run Code Online (Sandbox Code Playgroud)
云存储destination(文件夹和文件名)的正确语法是什么?
将存储桶从 更改myapp.appspot.com为myapp.appspot.com/Test_Folder导致错误消息:
Cannot parse JSON response
Run Code Online (Sandbox Code Playgroud)
此外,示例路径似乎指定了个人计算机硬盘驱动器上的位置。为Desktop. 这是否意味着有一种方法可以在 Cloud Storage 之外的某个地方指定目的地?
这是我的代码:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.Storage = functions.firestore.document('Storage_Value').onUpdate((change, context) => {
const {Storage} = require('@google-cloud/storage');
const storage = new …Run Code Online (Sandbox Code Playgroud) google-cloud-storage firebase google-cloud-functions firebase-storage
我正在编写由 Adam Freeman撰写的Pro Angular 9一书。第 8 行抛出错误:
private categories: string[] = [];
Run Code Online (Sandbox Code Playgroud)
错误是
Error: src/app/model/product.repository.ts:13:7 - error TS2322:
Type '(string | undefined)[]' is not assignable to type 'string[]'.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
Run Code Online (Sandbox Code Playgroud)
我不知道那条线是什么意思。变量如何既是字符串又是数组?
更让我困惑的是,Angular 说错误在第 13 行,而不是第 8 行。这是第 13 行:
Error: src/app/model/product.repository.ts:13:7 - error TS2322:
Type '(string | undefined)[]' is not assignable to type 'string[]'.
Type 'string | undefined' is not assignable to …Run Code Online (Sandbox Code Playgroud)