这是一个 2 部分的答案,第 1 部分遍历 Github 方向并在第 19 步结束。第 2 部分扩展了更多无法放入第 1 部分的信息,它将详细从第 19 步开始。我必须将其添加到另一个问题并将其链接到此问题。
以下是Github
按顺序列出的步骤。仅供参考,我将原始步骤与原始步骤保持一致,Github author
但在下面我放置了一堆子步骤,每个子步骤都有详细的解释和说明。
假设您已经创建了一个Firebase
项目并获得了GoogleService-Info.plist
文件
打开你的GoogleService-Info.plist
文件。以下variables
来自Github directions
相关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
步骤下面我都有评论,然后是指示。在我使用以下值的方向内,您应该使用您的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
并查询那些 2keys
然后在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),因为从那时起的所有步骤都发生在flashlight
文件夹内,而不是您的主 Xcode 项目的文件夹内。在你的 Xcode 项目的文件夹中什么都不会起作用,因为它没有 package.json 文件
第 1 部分 - Github 步骤:
1•安装并运行ElasticSearch或通过Heroku添加Bonsai服务
1.评论:
-Bonsai
将在第 10 步添加
- 在继续之前,您需要按顺序执行以下步骤 1A-1E
1.方向:
1A。Node.js
从https://nodejs.org/en/download/下载并安装
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.评论:
- 假设 Xcode 项目位于桌面上一个名为sneakerSearchFolder
-在终端内你cd
进入sneakerSearchFolder文件夹 - 即运行:cd Desktop/sneakerSearchFolder
clone
the github repo
-进入https://github.com/firebase/flashlight的sneakerSearchFolder
-重要你然后cd
到flashlight
文件夹即运行:cd flashlight
-您将需要node version
根据https://devcenter.heroku.com/articles/deploying-nodejs运行
-run:node -v
要获取文件夹node version
中正在运行的内容flashlight
(即v6.9.1
),稍后当您制作 a 时,Heroku instance
您将根据devcenter.heroku
上面的链接需要它
- 现在您在flashlight
文件夹中,如果node version
您刚刚运行的版本与步骤 1E 中的版本不匹配,您将需要更新 flashlight 文件夹中的版本以使其匹配。将 Node.js 升级到最新版本 如果两个版本都匹配,那么您不必担心这个
-假设您的节点版本匹配,打开package.json
文件夹中的flashlight
文件并添加一个"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
二维。跑:node -v
2E。打开flashlight
文件夹,然后打开package.json
. 将以下内容添加到文件中。
"engines": {
"node": "whatever_was_returned_from_Step_2D"
}
2E-示例。仅供参考,这是一个例子。打开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.评论:
- 你应该还在你的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
文件夹中,因为步骤 4BFB_SERVICEACCOUNT
需要从那里访问该文件。确保将文件放入FLASHLIGHT FOLDER
!
- 这未在 github 步骤中列出,但它是必要的。您必须添加Firebase Server SDK Credentials
到您的项目中
- 你需要在你的flashlight
文件夹中运行 $npm install firebase-admin --save
命令,否则你会得到错误,因为它会寻找一个packae.json
文件。该文件已经在您的flashlight
文件夹中,而不是在您的主 Xcode 项目的文件夹中
- 按照该部分内https://firebase.google.com/docs/server/setupInitialize the SDK
的说明进行操作。您将需要Unknown
文件中的 2 个值(现在应该重命名service-account.json
)来初始化它。这些值位于第 5-private_key
和 6-行clientEmail
。仅供参考clientEmail
和Firebase service account
是同一件事
-这就是你在initializing
里面的东西SDK
:
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
文件中复制key
命名client_email
或您可以复制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(见顶部注释,您必须至少设置FB_URL和FB_SERVICEACCOUNT)
4.评论:
- 在您的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
-on line 23exports.FB_SERVICEACCOUNT = process.env.FB_ACC || 'service-account.json';
是用于访问service-account.json file
步骤 3C 的内容(无需在此处添加或更改任何内容,因为它会自行访问)
-您现在必须设置数据所在的路径(例如用于将数据发送到上面 ViewController 内的 FB 的searchPath)、索引(第 17 步)和您想要的类型(类似于您的数据模型)监控第 64,65 和 66 行
exports.paths = [
{
path : "users",//line 64
index: "firebase",//line 65
type : "user"//line 66
},
-path
是你data
坐在里面的地方FB
。这是您要从 ie 中提取搜索结果的地方<DATABASE_URL>/searchSnkPath
-index
第 17 步中的 exp
-第 19 步type
中的 exp
-仅供参考,第 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...
-FYIFields
将keys
在 ES 中被索引。这是一个可选的添加。如果你有 10 个keys
并且只想要其中的 2 个,indexed
那么你会添加这个。这意味着 10 个键中只有 2 个keys
是可搜索的。您也可以使用文件中的parse函数config.js
来做同样的事情
- 然后保存/关闭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
文件的内容(只要您Unknown file
在步骤 3C 中重命名了就可以继续)
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.评论:
- 你不会在最后运行这个命令,所以现在跳过它,但你应该知道一些事情。Runningnode app.js
在您的本地机器上运行您的 Heroku 应用程序。它将在本地查找您没有的 ElasticSearch,因此您将收到连接错误。如果要在本地运行它,则必须export BONSAI_URL="<your_bonsai_url>"
在步骤 12B-Optional 处运行代码,这是解决本地连接错误所必需的。如果您的应用程序进入睡眠状态/崩溃(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.评论:
- 跳过此步骤,因为此时您ES
的 cpu 上没有要索引的本地
6.方向:
6.跳过这一步
7•cd手电筒
7.评论:
- 不需要运行它,你应该仍然在你的flashlight
文件夹中
7.方向:
7.跳过此步骤
8•heroku登录
8.评论:
- 打开终端
- 你必须输入你Heroku
的email address
,password.
当你输入密码时,它会显示为空白
8.方向:
8A。跑:heroku login
8B。在提示符处输入您的email address
并password
登录 Heroku
9•heroku create(将heroku添加到项目中)
9.评论:
- 这就是您不需要heroku
在第 1D 步创建应用程序的原因。现在您将创建并命名您的 heroku 应用程序
- 输入后,create
您需要输入您希望 Heroku 应用程序名称的任何名称。即我选择名字sneakersearchinstanceAtoZ
- 如果您登录后运行此命令Heroku
,您应该会看到列出的应用程序名称。转到右上角,单击9 dots
,选择Dashboard
9.方向:
9.运行:heroku create sneakersearchinstanceAtoZ
10•heroku插件:添加盆景(安装盆景)
10.评论:
- 在运行此步骤之前,您需要将一个添加credit card
到您的Heroku
帐户,否则在运行后它会说您必须这样做。不过,它仍然是一个免费计划。我不确定你是否可以添加一个Bonsai add on
没有卡的
-要添加信用卡一直到右侧,单击圆形图标,选择Account Settings
,然后选择Billing
-您现在需要添加bonsai
到您的heroku app
. 你通过运行来做到这一点heroku addons:add bonsai --app <your-app-name>
-<your-app-name>
是heroku
您在第 9 步中创建的应用名称
- 在你创建一个bonsai cluster
之后,它会希望你通过运行来打开集群heroku addons:open bonsai
10.方向:
10A。登录Heroku
并添加信用卡到Billing Page
10B。运行:heroku addons:add bonsai --app sneakersearchinstanceAtoZ
//与步骤 9 完全相同的名称
10℃。跑heroku addons:open bonsai
11•heroku 配置(检查盆景实例信息并复制您的新 BONSAI_URL,您稍后将需要它)
11.评论:
-Runningheroku config
会得到你所有的environment variables
值和它们对应的值。当您看到您的bonsai's url
, 复制它的值时,您将需要它来执行步骤 12B 和 17
- 这是您将在步骤 10C 中看到的完全相同的 url
-bonsai url
可能看起来像https://abc123a01:01abc12de45xyz34@xyz-012345.us-east-1.bonsaisearch.net
11.方向:
11A。跑:heroku config
11B。复制bonsai url
返回的
12•heroku config:set FB_NAME= FB_TOKEN="" (声明环境变量)
12.评论:
-12A 是必需的。您需要使用项目的GoogleService-Info.plist
whichPROJECT_ID
和FB_NAME
whichAPI_KEY
用于FB_TOKEN
此步骤
-12B 是可选的。如果你想连接到ElasticSearch
本地运行这个。您必须设置您的bonsai url
,以便运行node app.js
不会引发连接错误。您可以通过运行:export BONSAI_URL="<your_bonsai_url>"
. 您需要在每个终端会话或 Heroku 应用程序睡着/崩溃时运行此命令。
- 不要在等号前后使用空格
12.方向:
12A(必填)。跑:heroku config:set FB_NAME=sneakersearch-az12 FB_TOKEN=0012abc789xyz00019
12B(可选)。运行:export BONSAI_URL="https://abc123a01:01abc12de45xyz34@xyz-012345.us-east-1.bonsaisearch.net"
13•git add config.js (更新)
13.评论:
-如果你运行它,你可能会收到一条错误消息:
以下路径被你的 .gitignore 文件之一忽略: config.js 如果你真的想添加它们,请使用 -f。
- 它是说运行git add config.js
然后-f
在最后添加
13.方向:
13A。跑:git add config.js
13B。如果运行出错:git add config.js -f
14•git commit -m "配置盆景"
14.方向:
14.运行:git commit -m "configure bonsai"
15•git push heroku master(部署到heroku)
15.方向:
15.运行:git push heroku master
16•heroku ps:scale worker=1(启动dyno worker)
16.评论:
- 这个命令的答案在这里有人能解释一下“heroku ps:scale web=1”吗
16.方向:
16.运行:heroku ps:scale worker=1
17•curl -X POST /firebase(例如:
https://username:password@yourbonsai.bonsai.io/firebase)
17.评论:
-在开始此步骤之前,请阅读 @DoesData 更新的答案(在我的下方)以使用 curl -X PUT 而不是 POST
- 抓取bonsai url
您从步骤 11B 复制的内容
- 在命令后粘贴 urlcurl -X POST
并确保添加/firebase
到它的末尾
-它的作用是创建一个名为的索引,该索引/firebase
指向您的bonsai url
. 打开您的config.js
文件并查找exports.paths
(第 62 行)。它有一个名为index: "firebase"
(line 65) 的键/值对,该值指向您刚刚创建的索引并从那里访问 ES 集群
- 基本上在您的 config.js 文件中,第 65 行的index
值必须与您添加到 end命令firebase
的名称完全匹配。如果名称不匹配,那么这些都不起作用。/firebase
curl -X POST
- 如果成功,你应该得到这个回复:{"acknowledged":true}
17.方向:
17.运行:curl -X POST https://abc123a01:01abc12de45xyz34@xyz-012345.us-east-1.bonsaisearch.net/firebase
18•现在是时候使用第 5 步 node app.js(运行应用程序)了
18.评论:
- 运行此命令将在本地启动应用程序。您也可以运行npm start
,但无论哪种方式,它都会在您的本地计算机上启动它,您需要运行步骤 12B(可选)中的代码才能使其正常工作
18.方向
18.运行:node app.js
19• 设置您的映射对象
仅供参考,第 19 步非常重要。你必须设置你的映射对象和它的键。我没有足够的字符在这里详细解释它。这是第 4 步的type
关键用来设置的。观看此视频以说明如何设置您的mappings object
: https ://www.youtube.com/watch?v=h3i3pqwjtjA&feature=youtu.be
19.方向:
19A。--openTextEdit
或者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
如果它没有在某个时间范围内使用。要停止睡眠/崩溃,请遵循
防止 Heroku 空转的简单方法?
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 部分。