这是一个两部分的答案,第一部分遍历 Github 方向并在步骤 19 结束。第二部分扩展了更多信息,这些信息不适合第一部分,它将从步骤 19 开始详细说明。我必须将其添加到另一个问题并将其链接到此问题。
这里是按顺序列出的Github 步骤。仅供参考,我将原始步骤与原始 Github author 列出的方式保持一致,但在下面我放置了一堆子步骤,每个子步骤都有详细的解释和说明。
假设您已经创建了一个 Firebase 项目并获得了您的 GoogleService-Info.plist 文件
打开您的GoogleService-Info.plist 文件。以下来自Github directions 的variables 与GoogleService-Info.plist keys 相关
-FB_NAME is the same thing as your PROJECT_ID
-FB_URL is the same thing as your DATABASE_URL
-FB_TOKEN is the same thing as your API_KEY
So
-if your PROJECT_ID is "sneakersearch-az12" then your FB_NAME is "sneakersearch-az12"
-if your DATABASE_URL is "https://sneakersearch-az12.firebaseio.com" then your FB_URL is "https://sneakersearch-az12.firebaseio.com"
-if your API_KEY is "0012abc789xyz00019" then your FB_TOKEN is "0012abc789xyz00019"
//These are not inside your GoogleService-Info.plist but you will encounter them later
-FB_SERVICEACCOUNT pertains to downloading a json file from the your project's Firebase console. You will need to go to the page SERVICE ACCOUNTS it's exp in step 3B
-clientEmail is the same thing as your Firebase Service Account. You get this from either the Unknown file or on your SERVICE ACCOUNTS page via the FB Console and it's exp in step 3D and 3B
-privateKey is the same thing as private_key but this key is NOT your API_KEY, it is a key that is inside the Unknown file from the SERVICE ACCOUNTS page. It looks something like: "-----BEGIN PRIVATE KEY-----\nCYchgacopuyvpc017246t124087t6hpUTYVPUSVDPUCHVEpcl889ljbsiugr4ygrphvuygpuy...mutli-lines...\n-----END PRIVATE KEY-----\n". Also exp in step 3B
在每个Github 步骤下面我有cmets,然后是方向。在我使用以下值的说明中,您应该改用您的project's values。所以对于步骤示例,我将使用这些keys 和values:
//GoogleService-Info.plist
PROJECT_ID---aka--FB_NAME: sneakersearch-az12
DATABASE_URL-aka--FB_URL: https://sneakersearch-az12.firebaseio.com
API_KEY------aka--FB_TOKEN: 0012abc789xyz00019
//FB Service Account info
Firebase service account--aka--clientEmail: firebase-admin-81772@sneakersearch-az12.iam.gserviceaccount.com //this is auto generated for you once you've created your firebase project
//Heroku and Bonsai info
Heroku Instance Name--aka--Heroku App Name: sneakersearchinstanceAtoZ
BONASI_URL --aka--Bonsai Cluster URL: https://abc123a01:01abc12de45xyz34@xyz-012345.us-east-1.bonsaisearch.net
Swift 数据模型:(这将匹配您在第 19 步中放入映射对象的内容)
class Sneakers: NSObject{
var sneakercondition: String?
var sneakername: String?
}
带有文件路径的 VC,我将数据发送到 Firebase,searchSnkPath 是单独的文件路径,Bonsai 将在其中运行搜索:
@IBOutlet weak var conditionTextField: UITextField!
@IBOutlet weak var nameTextField: UITextField!
var dbRef: FIRDatabaseReference!
let userID = FIRAuth.auth()?.currentUser?.uid
override func viewDidLoad() {
super.viewDidLoad()
self.dbRef = FIRDatabase.database().reference()
}
@IBAction func postDataButton(){
var dict = [String:AnyObject]()
dict.updateValue(conditionTextField.text!, forKey: "sneakercondition")
dict.updateValue(nameTextField.text!, forKey: "sneakername")
let idPath = self.dbRef.child("users").child(userID!).child("sneakersPath").childByAutoId()
//searches will run on this file path
let searchSnkPath = self.dbRef.child("searchSnkPath").childByAutoId()
idPath.updateChildValues(dict){
(err, ref) in
searchSnkPath.updateChildValues(dict)
}
}
}
在FBDatabase 内部,我要搜索的数据的路径存储在root/searchSnkPath/autoID,它有2 个keys,分别命名为sneakercondition 和sneakername,代表数据。我要从中提取搜索结果的路径是root/searchSnkPath
root
|
@-users
| |
| @-userID
| |
| @-sneakersPath
| |
| @-autoID
| |-sneakercondition
| |-sneakername
@searchSnkPath
|
@-autoID
|-sneakercondition
|-sneakername
如果我想在searchSnkPath 上搜索并查询这两个keys,那么在config.js 文件中我会找到exports.paths,在里面我可以设置要搜索的信息
exports.paths = [
{
path : "https://sneakersearch-az12.firebaseio.com/searchSnkPath", //exp in Step 4
index: "firebase", //exp in Step 17
type : "sneakers", //exp in Step 19
fields: ['sneakercondition', 'sneakername'] //these are the specific keys to search on (exp in Step 4)
}
]
第 4 步涵盖了所有这些
重要在运行 git clone https://github.com/firebase/flashlight(步骤 2A)后,您需要将 cd 放入 flashlight 文件夹(步骤 2B),因为从那时起的所有步骤都发生在 @987654370 内@ 文件夹和 NOT 您的主要 Xcode 项目的文件夹。 在您的 Xcode 项目文件夹中没有任何功能,因为它没有 package.json 文件
第 1 部分 - Github 步骤:
1•安装并运行 ElasticSearch 或通过 Heroku 添加 Bonsai 服务
1.cmets:
-Bonsai 将在第 10 步添加
-在继续之前,您需要按顺序执行以下步骤 1A-1E
1.方向:
1A.从https://nodejs.org/en/download/下载并安装Node.js
1B. 在https://devcenter.heroku.com/articles/heroku-cli 下载并安装Heroku Toolbelt(已重命名为Heroku CLI)。仅供参考,我使用的是 OS X 安装程序,而不是 OS X Homebrew。
1C. 下载并安装 Heroku Toolbelt/CLI 后,登录 Heroku.com 并创建一个帐户
1D. 创建Heroku 帐户后,无需创建新的Heroku App 您将在第9 步中使用命令行执行此操作。这很容易
1E. 打开终端并运行:node -v 以找出当前运行的node version(例如你得到v6.9.1)。在第 2D 步中,您必须确保那里的版本与此输出匹配。
2•git克隆https://github.com/firebase/flashlight
2.cmets:
-假设 Xcode 项目位于桌面上名为 sneakerSearchFolder 的文件夹中
-在终端内你 cd 到sneakerSearchFolder 文件夹-即运行:cd Desktop/sneakerSearchFolder
-一旦进入sneakerSearchFolder你clonethe github repohttps://github.com/firebase/flashlight
-重要然后您将cd 转到flashlight 文件夹,即运行:cd flashlight
-根据https://devcenter.heroku.com/articles/deploying-nodejs,您将需要node version 运行
-run: node -v 获取node version 在flashlight 文件夹中运行的内容(即v6.9.1)稍后当您创建Heroku instance 时,您将根据上面的devcenter.heroku 链接需要它
-现在您在 flashlight 文件夹中,如果您刚刚运行的 node version 与步骤 1E 中的版本不匹配,您将需要更新 flashlight 文件夹中的版本以使其匹配。 Upgrading Node.js to latest version 如果两个版本都匹配,那么你不必担心这个
-假设您的节点版本匹配,打开您的flashlight 文件夹中的package.json 文件并添加一个"engines" 对象,其键值为您当前使用的node version
"engines": {
"node": "node_version_num_you_got_back_from_running_node -v"
}
2.方向:
2A. 在终端中导航到 Xcode 项目所在的任何文件夹
2B. 运行:git clone https://github.com/firebase/flashlight
2C. 运行:cd flashlight
2D. 运行:node -v
2E. 打开flashlight 文件夹,然后打开package.json。将以下内容添加到文件中。
"engines": {
"node": "whatever_was_returned_from_Step_2D"
}
2E-example。仅供参考,这是一个示例。打开package.json 并在"dependencies" closing brace 之后添加。务必在右大括号后添加逗号。并且不要在版本号前添加“v”。保存文件。
"dependencies": {
"JQDeferred": "~1.9.1",
"colors": "~0.6.2",
"elasticsearch": "^11.0.1",
"firebase": "^3.5.2"
},
"engines": {
"node": "6.9.1"
}
3•npm 安装
从这一点开始,您必须在 flashlight 文件夹中,而不是主项目的文件夹中才能正常工作,否则您将收到错误消息
3.cmets:
-你应该还在你的 flashlight 文件夹中
-登录Firebase,在您的FB项目的控制台中,转到Project's Settings(Overview旁边的小圆形图标),在项目设置中选择SERVICE ACCOUNTS,转到Firebase Admin SDK部分.你必须在这里做两件事。 1. 找到并复制您的 Firebase service account,它看起来像 firebase-admin-81772@sneakersearch-az12.iam.gserviceaccount.com 和 2. 在页面底部,您必须单击Generate New Private Key 按钮,它将下载一个Unknown file,您需要将其重命名为service-account.json。如果它将文件命名为 Unknown 以外的名称,只需将其重命名为 service-account.json。重命名文件后,将其拖到 flashlight 文件夹中,因为步骤 4B FB_SERVICEACCOUNT 需要从那里访问此文件。确保将文件放入FLASHLIGHT FOLDER!
-这没有在 github 步骤中列出,但它是必要的。您必须将Firebase Server SDK Credentials 添加到您的项目中
-您需要在 flashlight 文件夹中运行 $npm install firebase-admin --save 命令,否则您会收到错误,因为它会查找 packae.json 文件。该文件已经在您的 flashlight 文件夹中,而不是在您的主 Xcode 项目文件夹中
-按照https://firebase.google.com/docs/server/setup 的指示,在Initialize the SDK 部分内。您将需要 Unknown 文件(现在应该重命名为 service-account.json)中的 2 个值来初始化它。这些值位于第 5-private_key 和 6-clientEmail 行。仅供参考,clientEmail 和 Firebase service account 是同一回事
-这是SDK中的initializing:
var admin = require("firebase-admin"); //this imports the npm firebase-admin module you just installed
admin.initializeApp({
credential: admin.credential.cert({
projectId: "<PROJECT_ID>", //projectId: is the PROJECT_ID from your GoogleService-Info.plist file
clientEmail: "foo@<PROJECT_ID>.iam.gserviceaccount.com", //clientEmail: is on line 6 in the Unknown file which is also your "Firebase service account" info
privateKey: "-----BEGIN PRIVATE KEY-----\n<KEY>\n-----END PRIVATE KEY-----\n" //privateKey: is NOT your API_KEY/FB_TOKEN. Inside the Unknown file on line 5 there is a very long multiline "private_key" key. It looks something like "-----BEGIN PRIVATE KEY-----\nCYchgacopuyvpc017tEpcl889ljbsiugr4ygrphvuygpuy...mutli-lines...\n-----END PRIVATE KEY-----\n". You need to copy and paste it from there to here. Be sure to include the "-----BEGIN PRIVATE KEY-----\n and \n-----END PRIVATE KEY-----\n
}),
databaseURL: "https://<DATABASE_NAME>.firebaseio.com" //databaseURL: is the DATABASE_URL from your GoogleService-Info.plist file
});
-FYI 在Initialize the SDK 部分中,您还可以选择使用上面写着path/to/serviceAccountKey.json 的部分,并且您可以提供重命名的未知文件的路径。我选择底部的inline 部分,因为它更容易。如果您按照这些步骤操作,则无需担心这一点。
-在flashlight文件夹里面有一个app.js文件,把上面的代码复制粘贴到文件顶部
-在命令行运行返回内部终端:npm install
-如果一切正常,您应该收到的唯一警告是 No repository field 和 No license field
3.方向:
3A。确保您在 flashlight 文件夹中运行:pwd
3B. 登录您的Firebase Console 的SERVICE ACCOUNTS 页面并点击Generate New Private Key 按钮下载Unknown 文件。
3C. 将 Unknown 文件重命名为 service-account.json 并将文件放入您的 flashlight 文件夹中
3D。在service-account.json 文件中复制名为client_email 的key,或者您可以复制Firebase SERVICE ACCOUNTS 页面上的服务帐户信息
3E.内部终端运行:npm install firebase-admin --save
3F.复制Initialize the SDK部分内的内容并使用这些值初始化字段:
var admin = require("firebase-admin");
admin.initializeApp({
credential: admin.credential.cert({
projectId: "sneakersearch-az12", //use your PROJECT_ID
clientEmail: "firebase-admin-81772@sneakersearch-az12.iam.gserviceaccount.com", //clientEmail: is on line 6 in the Unknown file
privateKey: "-----BEGIN PRIVATE KEY-----\nCYchgacopuyvpc017tEpcl889ljbsiugr4ygrphvuygpuy...mutli-lines...\n-----END PRIVATE KEY-----\n" //privateKey: is on line 5 in the Unknown file
}),
databaseURL: "https://sneakersearch-az12.firebaseio.com" //use your DATABASE_URL
});
3G.在flashlight文件夹中,打开app.js文件,用正确的值粘贴/保存上面的代码
3H. 运行:npm install
4•编辑 config.js(见顶部的 cmets,您必须设置 FB_URL 和
至少 FB_SERVICEACCOUNT)
4.cmets:
-在你的flashlight文件夹中有一个名为config.example.js的文件,打开它
-在这个 config.example.js 文件中,您可以找到 FB_URL 和 FB_SERVICEACCOUNT 变量(它们在第 13 行和第 23 行列出)
-你需要把exports.FB_URL = process.env.FB_URL || 'https://<YOUR APP>.firebaseio.com';改成exports.FB_URL = process.env.FB_URL || 'whatever_your_DATABASE_URL_is';(一定要把whatever_your_DATABASE_URL_is放在单引号或者双引号里)
-第 23 行 exports.FB_SERVICEACCOUNT = process.env.FB_ACC || 'service-account.json'; 用于从步骤 3C 访问 service-account.json file(无需在此处添加或更改任何内容,因为它会自行访问)
-您现在必须设置数据所在的路径(例如用于将数据发送到上面 ViewController 内的 FB 的 searchPath)、索引(第 17 步)和类型(类似于您的数据模型)您要在第 64、65 和 66 行监控的
exports.paths = [
{
path : "users",//line 64
index: "firebase",//line 65
type : "user"//line 66
},
-path 是您的data 位于FB 内部的位置。这是您要从中提取搜索结果的地方,即<DATABASE_URL>/searchSnkPath
-index第17步中的exp
-type exp 在第 19 步
-仅供参考,第 69-79 行将设置您想要监控的另一条路径。您可以根据需要删除或注释掉这些内容。您还可以创建更多路径进行监控,即如果您有路径 <DATABASE_URL>/searchClothingPath,那么您也可以在该路径上设置搜索。如果您愿意,还可以添加更多路径,即:
exports.paths = [
{
path : "https://sneakersearch-az12.firebaseio.com/searchSnkPath"
index: "firebase",
type : "sneakers"
},
{
path : "<DATABASE_URL>/searchClothingPath"
index: "firebase",
type : "clothingDataModel",
fields: ['jeans','shirts']//completely optional to use
},
{
path : "<DATABASE_URL>/searchHatsPath"
index: "firebase",
type : "hatDataModel",
},
//etc...
-仅供参考 Fields 是将在 ES 中索引的 keys。这是一个可选的添加。如果你有 10 个 keys 并且只希望其中 2 个是 indexed 那么你会添加这个。这意味着这 10 个键中只有 2 个 keys 是可搜索的。你也可以使用config.js文件中的parse函数来做同样的事情
-之后保存/关闭config.example.js并将其重命名为config.js
4.方向:
4A.打开config.example.js文件并在第13行将exports.FB_URL = process.env.FB_URL || 'https://<YOUR APP>.firebaseio.com';更改为exports.FB_URL = process.env.FB_URL || 'https://sneakersearch-az12.firebaseio.com';
4B.第 23 行用于访问 service-account.json 文件(只要您在步骤 3C 中重命名了 Unknown file 即可继续)
4C. 第 64、65、66 行是我要监控的内容,在第 67 行我添加了 fields key 用于我想搜索的两个 Firebase Database Keys,尽管它不是必要的
exports.paths = [
{
path : "https://sneakersearch-az12.firebaseio.com/searchSnkPath",//line 64
index: "firebase",//line 65
type : "sneakers",//line 66
fields: ['sneakercondition', 'sneakername']//line 67
},
4D. 保存/关闭config.example.js 文件。现在将文件重命名为config.js。
5•node app.js(运行应用程序)
5.cmets:
-你不会在最后运行这个命令,所以现在跳过它,但你应该知道一些事情。运行 node app.js 在本地计算机上运行您的 Heroku 应用程序。它将在本地查找您没有的 ElasticSearch,因此您将收到连接错误。如果要在本地运行它,则必须在步骤 12B-Optional 处运行 export BONSAI_URL="<your_bonsai_url>" 代码,这是解决本地连接错误所必需的。如果您的应用程序进入睡眠状态/崩溃(exp 接近尾声),您将不得不再次运行export BONSAI_URL="<your_bonsai_url>" 命令。除此之外,当您将代码推送到 Heroku 时,它会自动运行该应用程序。
-到目前为止,对于这一步,您需要打开您的app.js 文件并根据https://docs.bonsai.io/docs/nodejs 添加一些代码。您应该在var elasticsearch = require('elasticsearch') 声明之后的任何位置添加代码。
/*
this code is already inside the app.js file. You should add the code anywhere below it
var elasticsearch = require('elasticsearch'),
conf = require('./config'),
fbutil = require('./lib/fbutil'),
PathMonitor = require('./lib/PathMonitor'),
SearchQueue = require('./lib/SearchQueue');
*/
//You need to add
var bonsai_url = process.env.BONSAI_URL;
var client = new elasticsearch.Client({
host: bonsai_url,
log: 'trace'
});
// Test the connection...
client.ping({
requestTimeout: 30000,
hello: "elasticsearch"
},
function (error) {
if (error) {
console.error('>>>My Bonsai url is>>>' + bonsai_url)
console.error('>>>Elasticsearch cluster is down!');
} else {
console.log('All is well');
}
}
);
-方向还说要运行 $export BONSAI_URL="https://username:password@my-awesome-cluster-123.us-east-1.bonsai.io"(换句话说,export BONSAI_URL="<your_BONSAI_URL>"),只有当您想在本地运行应用程序以使用 ES 时,您才会这样做。它不适用于远程
5.方向:
5.打开app.js文件并添加以下代码并保存文件:
var bonsai_url = process.env.BONSAI_URL;
var client = new elasticsearch.Client({
host: bonsai_url,
log: 'trace'
});
// Test the connection...
client.ping({
requestTimeout: 30000,
hello: "elasticsearch"
},
function (error) {
if (error) {
console.error('>>>My Bonsai url is>>>' + bonsai_url)
console.error('>>>Elasticsearch cluster is down!');
} else {
console.log('All is well');
}
}
);
6•curl -X POST http://localhost:9200/firebase
6.cmets:
-跳过这一步,因为此时你的 cpu 上没有本地 ES 来索引
6.方向:
6.跳过此步骤
7•cd 手电筒
7.cmets:
-不需要运行这个,你应该还在你的flashlight文件夹中
7.方向:
7.跳过此步骤
8•heroku 登录
8.cmets:
-打开终端
-您必须输入您的Heroku 的email address 和password. 当您输入密码时,它将显示为空白
8.directions:
8A. 运行:heroku login
8B.在提示符处输入您的email address 和password 以登录Heroku
9•heroku 创建(将heroku 添加到项目中)
9.cmets:
-这就是您不需要在步骤 1D 中创建 heroku 应用程序的原因。现在您将创建并命名您的 heroku 应用程序
-在您输入create 后,您需要输入您希望 Heroku 应用程序名称的任何名称。即我选择名称sneakersearchinstanceAtoZ
-如果您登录到Heroku,运行此命令后,您应该会看到列出的应用程序名称。到右上角,点击9 dots,选择Dashboard
9.directions:
9. 运行:heroku create sneakersearchinstanceAtoZ
10•heroku插件:添加盆景(安装盆景)
10.cmets:
-在运行此步骤之前,您需要将credit card 添加到您的Heroku 帐户,否则在运行后它会说您必须这样做。不过,它仍然是一个免费计划。我不确定你是否可以在没有卡的情况下添加Bonsai add on
-要添加信用卡一直到右侧,点击圆形图标,选择Account Settings,然后选择Billing
-您现在需要将bonsai 添加到您的heroku app。你可以通过运行heroku addons:add bonsai --app <your-app-name>
-<your-app-name> 是您在第 9 步中创建的 heroku 应用名称
-在您创建 bonsai cluster 之后,它会希望您通过运行 heroku addons:open bonsai 打开集群
10.directions:
10A.登录Heroku并将信用卡添加到Billing Page
10B. 运行:heroku addons:add bonsai --app sneakersearchinstanceAtoZ//与第 9 步完全相同的名称
10C.运行heroku addons:open bonsai
11•heroku 配置(检查盆景实例信息并复制您的新
BONSAI_URL 稍后会用到)
11.cmets:
-运行heroku config 将获得您所有的environment variables 及其对应的值。当您看到 bonsai's url 时,复制它的值,在步骤 12B 和 17 中需要它
-这是您将在步骤 10C 中看到的完全相同的网址
-bonsai url 可能看起来像 https://abc123a01:01abc12de45xyz34@xyz-012345.us-east-1.bonsaisearch.net
11.directions:
11A. 运行:heroku config
11B.复制返回的bonsai url
12•heroku 配置:设置 FB_NAME= FB_TOKEN=""(声明
环境变量)
12.cmets:
-12A 是必需的。您需要使用项目的GoogleService-Info.plist 的PROJECT_ID 这是FB_NAME 和API_KEY 这是这一步的FB_TOKEN
-12B 是可选的。如果你想在本地连接到ElasticSearch,运行这个。您必须设置您的bonsai url,以便运行node app.js 不会引发连接错误。您可以通过运行:export BONSAI_URL="<your_bonsai_url>" 来做到这一点。您需要在每个终端会话中运行此命令,或者如果您的 Heroku 应用程序进入睡眠状态/崩溃。
-不要在等号前后使用空格
12.directions:
12A(必需)。运行:heroku config:set FB_NAME=sneakersearch-az12 FB_TOKEN=0012abc789xyz00019
12B(可选).run:export BONSAI_URL="https://abc123a01:01abc12de45xyz34@xyz-012345.us-east-1.bonsaisearch.net"
13•git add config.js(更新)
13.cmets:
-如果你运行它,你可能会得到一个错误,上面写着:
您的 .gitignore 文件之一会忽略以下路径:
配置.js
如果您真的想添加它们,请使用 -f。
-意思是运行git add config.js,然后在末尾添加-f
13.directions:
13A. 运行:git add config.js
13B.如果有错误运行:git add config.js -f
14•git commit -m "配置盆景"
14.directions:
14. 运行:git commit -m "configure bonsai"
15•git push heroku master(部署到heroku)
15.directions:
15. 运行:git push heroku master
16•heroku ps:scale worker=1(启动 dyno worker)
16.cmets:
-这个命令的答案在这里Can someone explain "heroku ps:scale web=1"
16.directions:
16. 运行:heroku ps:scale worker=1
17•curl -X POST /firebase(例如:
https://username:password@yourbonsai.bonsai.io/firebase)
17.cmets:
-开始此步骤之前,请阅读@DoesData 更新的答案(在我的下方)以使用 curl -X PUT 而不是 POST
-获取您从步骤 11B 复制的 bonsai url
-在curl -X POST 命令后粘贴网址,并确保在其末尾添加/firebase
-它的作用是创建一个名为/firebase 的索引,该索引指向您的bonsai url。打开您的config.js 文件并查找exports.paths(第62 行)。它有一个名为 index: "firebase"(line 65) 的键/值对,该值指向您刚刚创建的索引并从那里访问 ES 集群
-基本上在您的 config.js 文件中,在第 65 行,index 值 firebase 必须与您添加到末尾 curl -X POST 命令的名称 /firebase 完全匹配。如果名称不匹配,那么这些都不起作用。
-如果成功,您应该会收到此回复:{"acknowledged":true}
17.directions:
17. 运行:curl -X POST https://abc123a01:01abc12de45xyz34@xyz-012345.us-east-1.bonsaisearch.net/firebase
18•现在是时候使用第 5 步 node app.js(运行应用程序)了
18.cmets:
-运行此命令将在本地启动应用程序。您也可以运行npm start,但无论哪种方式,它都会在您的本地计算机上启动它,您需要运行步骤 12B(可选)中的代码才能使其工作
18.directions
18. 运行:node app.js
19• 设置您的映射对象
仅供参考,第 19 步非常重要。你必须设置你的映射对象和它的键。我没有足够的字符在这里详细解释它。这就是第 4 步的 type 键用来设置的。观看此视频,了解如何设置您的 mappings object: https://www.youtube.com/watch?v=h3i3pqwjtjA&feature=youtu.be
19.directions:
19A. --打开TextEdit 或Sublime 然后创建一个文件并将其命名为sneakerfile.json。保存并将文件拖到您的flashlight 文件夹中。您需要.json 扩展名。
19B. - 在该文件中添加以下代码,保存并关闭文件:
{
"sneakers": {
"properties": {
"sneakercondition": {
"type": "string"
},
"sneakername": {
"type": "string"
}
}
}
}
//notice this is just like the Swift Sneakers Data Model declared at the beginning
19C. 抓住你的BONSAI_URL 运行heroku config:get BONSAI_URL。我的 BONSAI_URL 是 https://abc123a01:01abc12de45xyz34@xyz-012345.us-east-1.bonsaisearch.net
19D. 运行:curl -XPOST https://abc123a01:01abc12de45xyz34@xyz-012345.us-east-1.bonsaisearch.net/firebase/sneakers/_mapping -d@sneakerfile.json
19E. 运行:curl -XGET <BONASI_URL>/firebase/sneakers/_mapping?pretty
第 1 部分已完成。第 2 部分将详细解释第 19 步
更多信息-
Heroku 命令:
查看您的dyno
运行:heroku ps
如果您得到以下信息,请参阅下面的链接
=== web (Free): npm start (1)
web.1: crashed 2017/01/01 12:00:00 -0500 (~ 38m ago)
=== worker (Free): node ./app.js (1)
worker.1: crashed 2017/01/01 12:00:00 -0500 (~ 10m ago)
创建您的Heroku app 后,您的dyno 位于Heroku Free Plan 下。如果在某个时间范围内没有使用它,它最终会fall asleep/crash。要停止睡眠/崩溃,请关注
Easy way to prevent Heroku idling?
https://devcenter.heroku.com/articles/free-dyno-hours
https://devcenter.heroku.com/articles/dyno-sleeping
其他命令:
heroku help //help
heroku status //Heroku platform status
heroku logs //displays 100 logs
heroku logs --tail //realtime logs
heroku logs --tail | grep worker //dyno worker logs
heroku ps -a <heroku app name> //how many dyno hrs you have left
heroku config:get BONSAI_URL //gets only your bonsai url
heroku config //all your environment variables
heroku apps:info //your Heroku credentials
回到command prompt按Ctrl+C
您也可以联系 Heroku 支持或 Bonsai 支持,因为他们非常有帮助
我很快就会发布第 2 部分。