<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Denise Gosnell</title>
    <description>The latest articles on DEV Community by Denise Gosnell (@denisegosnell).</description>
    <link>https://dev.to/denisegosnell</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F767695%2F5a4aa2f0-e2d5-403b-a63c-6f07eccb198c.jpg</url>
      <title>DEV Community: Denise Gosnell</title>
      <link>https://dev.to/denisegosnell</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/denisegosnell"/>
    <language>en</language>
    <item>
      <title>Announcing: Stargate 1.0 GA; REST, GraphQL, &amp; Schemaless JSON for Your Cassandra Development</title>
      <dc:creator>Denise Gosnell</dc:creator>
      <pubDate>Thu, 27 Oct 2022 20:36:27 +0000</pubDate>
      <link>https://dev.to/datastax/announcing-stargate-10-ga-rest-graphql-schemaless-json-for-your-cassandra-development-24ia</link>
      <guid>https://dev.to/datastax/announcing-stargate-10-ga-rest-graphql-schemaless-json-for-your-cassandra-development-24ia</guid>
      <description>&lt;p&gt;It is a really great time to be a developer.&lt;/p&gt;

&lt;p&gt;We have tons of APIs integrated within great tools for building dynamic, full stack apps. If you are a developer, you probably are using technologies like schemaless data stores, serverless architectures, JSON APIs, and/or the GraphQL language.&lt;/p&gt;

&lt;p&gt;Further, there are a bunch of cool frameworks like the Jamstack (JavaScript, APIs, and Markup) and services like Netlify to make it fast to deploy a serverless app.&lt;/p&gt;

&lt;p&gt;And now, for the first time ever, Apache Cassandra is a part of this stack because &lt;a href="https://astra.dev/3sCwwMr" rel="noopener noreferrer"&gt;Stargate is now live on Astra&lt;/a&gt; as the official data API.&lt;/p&gt;

&lt;p&gt;The modern apps we build need data APIs which integrate into our toolset and work with native data shapes (JSON, REST, GraphQL, etc). These data APIs need to support schemaless JSON, while simultaneously providing speed and scalability.&lt;/p&gt;

&lt;p&gt;Most importantly, it better only take a few minutes for us to use them within our project.&lt;/p&gt;

&lt;p&gt;DataStax built &lt;a href="https://stargate.io/" rel="noopener noreferrer"&gt;Stargate&lt;/a&gt; into Astra to give us, app developers, a natural data API stack which meshes with the Jamstack (or serverless stack of your choice). Stargate in Astra is built on the rock solid NoSQL data engine (Apache Cassandra) which powers Netflix, Instagram, Yelp, iCloud and other apps we all use everyday.&lt;/p&gt;

&lt;h2&gt;
  
  
  What exactly is Stargate?
&lt;/h2&gt;

&lt;p&gt;Stargate is an &lt;a href="https://stargate.io/2020/09/14/init-stargate.html" rel="noopener noreferrer"&gt;open source data gateway&lt;/a&gt; that sits between your app server and your databases. Stargate brings together an API platform and data request coordination code into one OSS project.&lt;/p&gt;

&lt;p&gt;Multiple successful app companies - like Netflix and Yelp - built their own data gateways to help internal app developers create features using simple APIs, without needing to learn the underlying database or mess with schema.&lt;/p&gt;

&lt;p&gt;DataStax integrated Stargate into Astra to give you the same power and ease of access to your data.&lt;/p&gt;

&lt;p&gt;What does this mean for you?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No upfront data modelling needed for Documents.&lt;/li&gt;
&lt;li&gt;Less custom code to maintain.&lt;/li&gt;
&lt;li&gt;More time to build what you care about.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcfeqpg9jz8fwj6e08a32.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcfeqpg9jz8fwj6e08a32.png" alt="Image description" width="800" height="499"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can work with your data the way you want – JSON via schemaless document APIs or database schema aware GraphQL and RESTful APIs – while Stargate serves as the proxy that coordinates these requests to different flavors of Cassandra.&lt;/p&gt;

&lt;p&gt;To see it in action, let’s see how this works by using JSON with Stargate’s schemaless Document API in a TikTok clone. Because, if Instagram and Snapchat have a TikTok clone, we should have one, too. Right?&lt;/p&gt;

&lt;h2&gt;
  
  
  Real Quick Note First
&lt;/h2&gt;

&lt;p&gt;Slinging JSON to and from Apache Cassandra without data modeling is just too much fun. You gotta &lt;a href="https://astra.dev/3sCwwMr" rel="noopener noreferrer"&gt;try this out in Astra for yourself&lt;/a&gt;. You can get &lt;a href="https://www.datastax.com/dev/documents-api" rel="noopener noreferrer"&gt;hands on with it right away&lt;/a&gt; or check out our &lt;a href="https://astra.datastax.com/sample-app-gallery" rel="noopener noreferrer"&gt;sample app gallery&lt;/a&gt; to see schemaless Cassandra in action.&lt;/p&gt;

&lt;p&gt;We are stoked to have engineers from Netflix, Burberry, Macquarie Bank, USAA, and Yelp creating Stargate with us. They are already hard at work battletesting the APIs and collaborating on new features.&lt;/p&gt;

&lt;p&gt;Ok, onto the code!&lt;/p&gt;

&lt;h2&gt;
  
  
  Posts in TikTok
&lt;/h2&gt;

&lt;p&gt;We are going to walk through using Stargate’s APIs in Astra for creating and updating posts within a TikTok clone. We’re walking through examples that are ready to be pasted into your latest Jamstack app.&lt;/p&gt;

&lt;p&gt;To use Stargate in Astra in your app, first install and set up our &lt;a href="https://www.npmjs.com/package/@astrajs/collections" rel="noopener noreferrer"&gt;JavaScript SDK&lt;/a&gt;. You can learn about storing environment &lt;a href="https://www.youtube.com/watch?v=vSmzEGZQI5A" rel="noopener noreferrer"&gt;variables in your .env file here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let’s start with a basic TikTok post: a video with a caption, like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const postData = {
  "postId": 0,
  "video": "https://i.imgur.com/FTBP02Y.mp4",
  "caption": "These ducks are cute",
  "timestamp": "2020-12-09T09:08:31.020Z",
  "likes": 0,
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After connecting to Stargate in Astra with a nodejs client, let’s create a new collection in our app and add the post with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const postsCollection = astraClient.namespace("tikTokClone").
  collection("posts");

const post = await postsCollection.create(postData);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you’ve ever used Cassandra before, you know this is amazing. Look at what we didn’t do: no data modeling, no table creation, no configuration code, no partition keys, no clustering columns. I think you get my drift.&lt;/p&gt;

&lt;p&gt;Stargate in Astra allows you to add data to Apache Cassandra in one line of code.&lt;/p&gt;

&lt;p&gt;This level of ease of use hasn’t previously been possible with Cassandra. Insert JSON and move on.&lt;/p&gt;

&lt;p&gt;Next up, let’s say you want to find all posts about ducks. You can do that via:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// find all posts about ducks
const posts = await postsCollection.find({ caption: 
  { $in:  ["ducks"] } });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And boom. Now you have your ducks channel all set up for your users. Because who doesn’t want a stream fully dedicated to ducks?&lt;/p&gt;

&lt;p&gt;Now, your app isn’t going to &lt;a href="https://www.newsweek.com/twitter-fleets-reactions-memes-edit-button-1548037" rel="noopener noreferrer"&gt;be like Twitter&lt;/a&gt;. We can edit stuff here. Let’s show how to edit your post’s caption. Stories tho? That’s on you&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// update the post's caption
const post = await postsCollection.update(post.documentId, {
  caption: "These ducks are MEGA cute",
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above was just a quick tour on how to do a few data API calls for a basic TikTok clone. Want to see the full thing? Check out &lt;a href="https://www.youtube.com/watch?v=IATOicvih5A" rel="noopener noreferrer"&gt;Ania Kubow&lt;/a&gt;’s tutorial to see how to wire this up into a full React app with Netlify.&lt;/p&gt;

&lt;h2&gt;
  
  
  What’s next?
&lt;/h2&gt;

&lt;p&gt;For more examples, we have hands-on tutorials for using &lt;a href="https://www.datastax.com/dev/rest" rel="noopener noreferrer"&gt;Stargate’s REST&lt;/a&gt;, &lt;a href="https://www.datastax.com/dev/documents-api" rel="noopener noreferrer"&gt;Document&lt;/a&gt; and &lt;a href="https://www.datastax.com/dev/graphql" rel="noopener noreferrer"&gt;GraphQL APIs&lt;/a&gt;. Check ‘em out and let us know what you think.&lt;/p&gt;

&lt;p&gt;Have an app idea or want to join the fun? &lt;a href="https://discord.gg/2Xt8QNyFZA" rel="noopener noreferrer"&gt;You can join the Stargate community, too&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We would love to see how you customize your TikTok clone to show off more ways to feature data in your app. Or, you can create your own non-TikTok example. We would love to showcase your example in our &lt;a href="https://astra.datastax.com/sample-app-gallery" rel="noopener noreferrer"&gt;sample app gallery&lt;/a&gt;, so tell us about it in &lt;a href="https://discord.gg/33mKDHHFUE" rel="noopener noreferrer"&gt;our contribute channel&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  So, you are down here looking for a few more details
&lt;/h2&gt;

&lt;p&gt;If you came down here, maybe you are looking for a few more lines of code.&lt;/p&gt;

&lt;p&gt;No problem.&lt;/p&gt;

&lt;p&gt;Let’s show how to set up the node JS client and a few more data API calls. For starters, let’s take a look at how to set up your client to connect to Stargate in Astra.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// npm install @astrajs/collections
const { createClient } = require("@astrajs/collections");

// create an Astra client
const astraClient = await createClient(
{   astraDatabaseId: process.env.ASTRA_DB_ID,
    astraDatabaseRegion: process.env.ASTRA_DB_REGION,
    username: process.env.ASTRA_DB_USERNAME,
    password: process.env.ASTRA_DB_PASSWORD,
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Easy enough.&lt;/p&gt;

&lt;p&gt;Then, let’s create a users collection in our database to store documents about our TikTok users:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// create the users collection in the app
const usersCollection = astraClient.namespace("tikTokClone").collection("users");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A TikTok user in our app will have the basics: a unique id, a name, username, etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const userData = {
  "id_3": "0",
  "name": "Mo Farooq",
  "username": "mofarooq32",
  "avatar": "https://i.imgur.com/9KYq7VG.png"
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, let’s add our user into our collection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// create a new user
const user = await usersCollection.create(userData);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can check to make sure your user was stored in the database by reading the user back by any of their properties, like their username.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// find our user by username
const users = await usersCollection.find({ username: { $eq: 
  "mofarooq32" } });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, you can lookup a user by their documentId:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// get the user by document id
const user = await usersCollection.get(user.documentId);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And, lastly, if you need to delete that user:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// delete the user
const user = await usersCollection.delete(user.documentId);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Want to see the full code? Check out &lt;a href="https://github.com/kubowania/stargate-tik-tok" rel="noopener noreferrer"&gt;Ania Kubow’s app&lt;/a&gt; to get all the goodness and start customizing it on your own. Let me know when you have stories up and I can subscribe to your ducks channel.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
