保存前验证 Firebase JSON 的结构

validating structure of Firebase JSON before saving

我正在接触 Firebase。我有很强的MS SQL Server 数据库背景。您如何验证保存在 Firebase 中的 JSON 数据以匹配特定结构?有没有办法将 'interface' 应用于 JSON 以确保我们拥有正确的结构?不然你怎么对保存的数据有信心?

架构!听起来你会喜欢 the Bolt compiler!

Bolt 编译器是您在 Firebase 中表达模式的方式。

使用 Bolt,您可以将类型表达为模式,然后将其应用于存储数据的路径。

// Create the schema for a Post type
type Post {
  title: String;
  author: String;
  description: String;
  timestamp: Number;
  isPublished: Boolean;
}

// All data stored at "/posts" will conform to the Post type above
path /posts is Post;

还有一个 quick-start and guide 可以帮助您入门。