Luckily for us, Synth supports JSON out of the box so this can be done quite easily with the mongoexport command - a light weight tool that ships with MongoDB to enable quick dumps of the database via the CLI. We need to export data from MongoDB into a format that Synth can ingest.There are two steps to feed data into Synth from our MongoDB instance: To create a namespace, we need to feed some data into Synth. A visual example of the namespace/collection hierarchy can be seen below. Namespaces in turn, have collections which are kind of like tables in SQL-land. Fields in a namespace can refer to other fields in a namespace - but you cannot reference data across namespaces. Namespaces are the equivalent of Schemas in SQL-land. The namespace is the top-level abstraction in Synth. So let's create sub-directory called data/ and initialize our Synth workspace. All information pertaining to a workspace is in its directory. synth/ sub-directory.Ī workspace can have zero or more namespaces, where the namespaces are just represented as sub-directories. Synth figures how to build it for you □Ī workspace represents a set of synthetic data namespaces managed by Synth. With Synth you specify what your desired dataset should look like, not how to make it. You don't specify how to get to your end-state, you just specify what you want and the underlying program will figure out how to get there. Programming frameworks like SQL or React or Terraform are declarative. Most popular programming languages like Java or C are imperative - your code is step-by-step instructions on how to reach an end state. On the other had, an imperative model (which is what we are mostly used to), is step by step instructions on how to get to our end-state. Hmmm, so what is a declarative model you may ask? A declarative model, as opposed to an imperative model, is where you 'declare' your desired end state and the underlying program will figure out how to get there. Synth uses a declarative data model to specify how data is generated. If you are feeling adventurous, you can even build from source! To install Synth on MacOS / Linux, visit the docs and choose the appropriate installation for your OS. And finally generate a bunch of fake data from Synth and back into Mongo.Next will ingest data from MongoDB into Synth.Then we'll initialize a Synth workspace in our repo to host our data model.In the following section we will cover how Synth fits into the Web App development workflow: Ok, so now that we have a couple of movies, let's get started with Synth! So, let's add a couple of movies manually using the Web UI. Otherwise we would have to write the entire data definition (what we call a Schema) by hand. Well, by adding a little bit of test data by hand, we can then use Synth to infer the structure of the data and create as many movies as we want for us. Why are we adding movies by hand since we have a tool to generate data for us? For our purposes, we don't really need to build it from scratch, so let's just clone the repo and avoid writing any code ourselves.Įnter fullscreen mode Exit fullscreen modeĬool! If you navigate to you should see the React App running □ I picked this example because it shows how to get started quickly with a MERN stack, where the end product is a usable app you can write in 10 minutes. Īs a template, we'll use a repository which will give us scaffolding for the MERN app. I'm going to assuming you're working on MacOS or Linux (Windows support coming soon □) and you have NodeJS, Yarn and Docker installed.įor this example we'll be running Synth version 0.3.2. This tutorial is going to use a simple MERN ( Mongo Express React Node) web-app as our test subject, but really Synth is not married to any specific stack. Synth is a state-of-the-art declarative data generator - you tell Synth what you want your data to look like and Synth will generate that data for you. In this post we're going to explore how we can solve this problem using the open-source project Synth. You're building a Web App, you're super productive in your stack and you can go quickly - however generating lot's of data to see what your app will look like with enough users and traffic is a pain.Įither you're going to spend a lot of time manually inputting data or you're going to write some scripts to generate that data for you.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |