Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 260
Tom Schreck Avatar asked Jul 15 '26 12:07

Tom Schreck


1 Answers

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.

like image 190
David East Avatar answered Jul 18 '26 04:07

David East