Tom Schreck
Tom Schreck

Reputation: 5287

validating structure of Firebase JSON before saving

I'm getting my feet wet with Firebase. I have a very strong MS SQL Server database background. How do you validate the JSON data being saved in Firebase to match a particular structure? Is there a way to apply an 'interface' to the JSON to make sure we have the correct structure? Otherwise, how do you have any confidence in the data being saved?

Upvotes: 3

Views: 935

Answers (1)

David East
David East

Reputation: 32614

Schema! Sounds like you'd love the Bolt compiler!

The Bolt compiler is how you express schema in Firebase.

With Bolt, you can express types as schema and then apply it the path where the data is stored.

// 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;

There's also a quick-start and guide to help you get started.

Upvotes: 3

Related Questions