iCloud開發--Using CloudKit Dashboard to Manage Databases

你可以使用CloudKit儀表板執行許多數據庫管理任務。例如,你可以使用CloudKit儀表板修改模型和記錄。一個容器的數據庫可以同時在開發和生產環境存在。您可以執行的操作取決於你是否在開發或生產環境。

去CloudKit儀表板,登錄,然後在左側欄中的選項,探索CloudKit儀表板的功能。


1.About the Development and Production Environments

The development environment is used to create a schema and add records for testing. The production environment is accessed by apps sold on the App Store or Mac App Store. An app in development, can access either the development or the production environment. However, an app sold on the store can access only the production environment.開發環境是用來創建一個模式和用於測試添加記錄。生產環境是通過在App Store或Mac App Store的應用程序訪問的。在開發環境中的應用程序,可以訪問無論是開發或生產環境。然而,在商店出售的應用程序只能訪問生產環境。

In the development environment, CloudKit automatically creates the schema for you based on the records that you save to the database. This feature allows you to iterate and refine your schema without having to explicitly create it. You can also use CloudKit Dashboard to modify the schema and add records.在開發環境中,CloudKit自動創建基於您要保存到數據庫中記錄的架構。此功能允許您遍歷而無需顯式地創建優化您的架構。您還可以使用CloudKit儀表板修改架構,並添加記錄。


The first time you deploy the schema, the schema is copied to the production environment (records are not copied to the production environment). The next time you deploy the schema, the schema is merged with the production schema. To prevent conflicts, you can’t delete attributes or record types in a development schema that were previously deployed to the production environment.當您第一次部署架構,該架構將被複制到生產環境(記錄不會被複制到生產環境)。下一次當你部署架構,該架構融合的生產模式。爲了防止衝突,則無法刪除先前部署到生產環境,發展模式的屬性或記錄類型。


In the production environment, you can’t change the schema but you can add, modify, and delete records in the public database.在生產環境中,你無法改變模式,但你可以在公共數據庫中添加,修改和刪除記錄。


When you run your CloudKit app through Xcode, it is automatically configured to use the development environment. When you export your app from Xcode for testing, you specify either the development or production environment. When you submit your app to the store, it is configured to use the production environment.當您通過Xcode中運行你的CloudKit應用程序,它會自動配置使用開發環境。當您從Xcode中導出測試您的應用程序,您來指定用開發或生產環境。當您提交您的應用程序商店,它被配置爲使用生產環境。


2.Select Your Container

All of the functions in CloudKit Dashboard apply to the currently selected container. Switch the container usingthe pop-up menu in the upper-left corner. CloudKit Dashboard displays all the containers belonging to all theiOS Developer Program and Mac Developer Program teams you belong to. Be sure to select the container usedby the app that you are developing before performing any of the tasks in this chapter. 


3.Reset the Development Environment

If you use just-in-time schema to populate a database with records, as described in Creating Databases by Saving Records (page 15), you can reset the development environment between runs of your app. If you have never deployed your development environment, resetting the development environment deletes all the records and record types. Otherwise, it deletes all the records and returns the schema to the state of the production environment.如果你只使用即時模式來填充記錄的數據庫,如通過上節內容Creating Databases by Saving Records創建數據庫描述,您可以重置您的開發環境。如果你從來沒有部署你的開發環境,重置開發環境將刪除所有記錄,記錄類型。否則,將刪除所有記錄並返回模式到生產環境的狀態。

3.1 To reset the development environment
1. In CloudKit Dashboard, click Deployment in the left column.
2. Click Reset Development Environment.
3. In the dialog that appears, read the warning, select the checkbox, and click Reset & Delete Data.



4.Create and Delete Record Types

In the development environment, you can create, modify, and delete record types using CloudKit Dashboard.
4.1To create a record type  創建一個記錄類型
1. In CloudKit Dashboard, click Record Types under Schema. The schema’s record types appear in the second column.
2. Click the Add button (+) in the upper-left corner of the detail area.

3. Enter a name in the Record Type Name field.

4. Enter an attribute name, and select an attribute Type from the pop-up menu.
5. To add an attribute, click Add Attribute, enter an attribute name, and select an attribute type.
6. To delete an attribute, click the Delete button (x) in the row of the attribute.
The Delete button appears when you hover over the row. If the attribute is deployed, the Delete button is disabled.
7. Click Save.


You can delete a record type only in the development environment and only when that record type is not deployed. When you delete a record type, all its associated records are deleted from the database too.

4.2To delete a record type

1. In CloudKit Dashboard, click Record Types under Schema. The schema’s record types appear in the second column.
2. Select the record type you want to delete.
3. Click the trash icon in the upper-left corner of the detail area.
If the record type is deployed, the trash icon is disabled.
4. In the dialog that appears, click Delete.


5.Add, Modify, and Delete Records
In the development and production environment, you can add, modify, and delete records in public databases using CloudKit Dashboard.
5.1To create a record
1. In CloudKit Dashboard under Public Data or Private Data, click a zone.  
For example, in the public database, click Default Zone. (The User Records zone contains records of type Users created by CloudKit.)
2. In the second column, choose the record type from the pop-up menu in the upper-left corner.
3. In the detail area, click the Add button (+).
CloudKit Dashboard assigns a random UUID as the record ID.
4. Enter values in the text fields.

   5. For Date/Time types, enter the calendar date and the time values in separate fields.


5.2To view, modify, or delete a record

1. In CloudKit Dashboard, click the zone under Public Data or Private Data.
2. In the second column, choose the record type form the pop-up menu.
3. Select the record you want to view, edit, or delete.
The record attributes appear in the detail area.
4. To edit a record, enter new values in the text fields and click Save.
5. To delete a record, click the trash icon in the upper-left corner of the detail area.


6.Recap 概括
This chapter introduces you to managing your databases with CloudKit Dashboard. You learned how to:
Reset the development environment to a known state
Create and delete record types 

Create and edit records

本章介紹CloudKit儀表板管理數據庫。你學會了如何:
重置開發環境到已知狀態
創建和刪除記錄類型
創建和編輯記錄


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章