{"id":1671,"date":"2023-03-21T11:30:46","date_gmt":"2023-03-21T11:30:46","guid":{"rendered":"https:\/\/www.workfall.com\/learning\/blog\/?p=1671"},"modified":"2025-09-22T04:17:53","modified_gmt":"2025-09-22T04:17:53","slug":"use-surrealdb-to-persist-data-with-rocket-rest-api","status":"publish","type":"post","link":"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/","title":{"rendered":"Use SurrealDB to Persist Data with Rocket REST API"},"content":{"rendered":"<span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">8<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/EKQ4bNzqforM-6hxEs6tPVFQBYveEs8GnLIE4UKCAlY5aArHfA5PerHj_CBU0qQDMkpaIQTM1Gz8rE0HNdPh9C4Wwilr9AFvgLJLxONahQEzCHCk5AXA-lvqrVdJZjZ0NkriZePMJTtWsh5AqTHheDg\" alt=\"SurrealDB\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Databases are essential in web development for organizing data in various forms and shapes (both structured and unstructured). Their ultimate goal is for the stored data to be easily retrievable, updated, queried, and generally administered via a graphical user interface (GUI), dashboard, or even command line interface (CLI).<\/p>\n\n\n\n<p class=\"has-text-align-justify\">We can use database management systems to perform all database actions through a graphical user interface. With these GUIs, we can get a bird&#8217;s-eye view of all the data in our database for easy analysis of the schema or data types, as well as general ease of administration.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">SurrealDB shortens development time for modern applications by simplifying the entire database and API stack, eliminating the need for most server-side components. This allows you to quickly and cheaply build secure and performant apps. Its design allows it to run in a variety of environments, including embedded or distributed cloud environments.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">Furthermore, because it is a cloud-hosted database, it is simple to host or deploy because SurrealDB can be deployed anywhere, including the SurrealDB Cloud. It can be hosted in the cloud, on-premises, embedded, or edge computing environments in general.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">SurrealDB is the solution for database administration, which includes general admin and user management, enforcing data security and control, performance monitoring, maintaining data integrity, dealing with concurrency transactions, and recovering information in the event of an unexpected system failure.<\/p>\n\n\n\n<p>In this blog, we\u2019ll explore:<\/p>\n\n\n\n<ul><li>What is SurrealDB?<ul><li>What is Jamstack?<\/li><li>SurrealDB for Jamstack &amp; Serverless Applications<\/li><li>Why use SurrealDB?<\/li><li>Features of SurrealDB<\/li><li>SurrealDB vs. PostgreSQL<\/li><li>Rocket REST API<\/li><\/ul><\/li><li>Hands-on<\/li><li>Conclusion<\/li><\/ul>\n\n\n\n<h2>What is SurrealDB?<\/h2>\n\n\n\n<p class=\"has-text-align-justify\">SurrealDB is a serverless document-graph web database that is flexible, developer-friendly, and fully ACID transactional. Never again will you have to be concerned about database provisioning, scaling, sharding, replication, or correctness.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">SurrealDB claims to be the ultimate cloud database for all types of applications, according to the documentation. It is a cloud-native, end-to-end database that supports most traditional applications, including web and mobile. It can also be used for backend-based applications such as <strong>Serverless<\/strong> and <strong>Jamstack<\/strong>.<\/p>\n\n\n\n<h3>What is Jamstack?<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/TUCoJfXF0sFmajPAevpCmYntcxOlm6ShpwjUkt6uEjprU1g3UNJAX72t7jk82hOQsLUOHcFzAiBTcl2gmA1eazNHiacjJOuF1t5ocmLQItGNrzuC3fY7FjPURk5uHNSclQhO4X2cb8k-bWOiEjniHhI\" alt=\"Jamstack\"\/><\/figure>\n\n\n\n<h3>SurrealDB for Jamstack and Serverless Applications<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/nZTufq0Y1KYKQqfkmeck8cQKia7jYmjs_sP4PSCunMR81hQqznLXP0PEd34nM6HheMBXVCMXWw5FbXYVdFiwlpqZkTopW1hvh5trQQZ-4HT7ExLdED_kTzML9Fnf8Bu1Ez92U2IZm9hYVDaGNszIj8o\" alt=\"Jamstack &amp; Serverless\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">SurrealDB&#8217;s ability to function as both a database and a real-time collaborative API backend layer is one of its advantages. This means it can function as a single, plug-and-play database server. It is highly available, scalable, and distributed, and it supports:<\/p>\n\n\n\n<ul><li>SQL querying from client devices<\/li><li>GraphQL<\/li><li>ACID transactions<\/li><li>WebSocket connections<\/li><li>Both structured and unstructured data<\/li><li>Graph querying<\/li><li>Full-text indexing<\/li><li>Geospatial querying<\/li><li>Row permission-based access<\/li><\/ul>\n\n\n\n<p class=\"has-text-align-justify\">SurrealQL is an out-of-the-box SQL-style query language included with SurrealDB. SurrealQL supports real-time queries, faster and more performant query processing, advanced permissions, and access control for multi-tenant applications. SurrealDB also asserts that it is the next-generation database for serverless applications.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">SurrealDB is a NoSQL database, which eliminates the need for the majority of server-side components and layers that are typically required when using other types of database systems. It is adaptable and can easily fit into any type of technology stack. You can also start it with a simple command or a direct connection to a client-side application.<\/p>\n\n\n\n<p>It also works when there are multiple queries or analytics to be performed on a server.<\/p>\n\n\n\n<h3>Why use SurrealDB?<\/h3>\n\n\n\n<p class=\"has-text-align-justify\">SurrealDB is an innovative NewSQL cloud database that is suitable for serverless, jamstack, single-page, and traditional applications. Its versatility and financial value are unparalleled, with the ability to deploy on the cloud, on-premise, embedded, and edge computing environments. Get started with SurrealDB Cloud in one click for a simple setup.<\/p>\n\n\n\n<p>It has a very specific advantage in that there is no need for a complex database and backend setup.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">SurrealDB also handles the majority of security rules on your behalf. It provides advanced table- and row-based, customizable access permissions for different types of users, allowing granular data access patterns.<\/p>\n\n\n\n<h3>Features of SurrealDB<\/h3>\n\n\n\n<p class=\"has-text-align-justify\">SurrealDB is so simple to set up and use that your engineering team will be up and running in no time. There is no need to waste time learning a new query language or syntax because the method of querying your data in previous databases works immediately. It is a fast and highly performant database that can scale to meet your needs. It has the following features:<\/p>\n\n\n\n<ul><li><strong>Distributed ACID transactions:<\/strong> SurrealDB handles scalability behind the scenes, leaving developers with few operational and management tasks. This is because SurrealDB handles manually creating and allocating additional databases or server resources by default, allowing it to be highly available, distributed, and ACID-compliant.<br><\/li><li><strong>No complex backend servers or APIs: <\/strong>SurrealDB allows us to specify both the database and the API schema in one place. Once a schema is defined, database access is granted automatically to the appropriate parties, eliminating the need for custom code or integration.<br><\/li><li><strong>Support for multi-tenancy:<\/strong> SurrealDB allows us to connect directly to various end-user devices and run SurrealQL queries from web browsers. This means that users can only see or edit the data to which they have been granted access.<br><\/li><li><strong>Inbuilt access and permissions:<\/strong> SurrealDB&#8217;s direct client connection provides built-in permissions, which speeds up the development process.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/lxZqkIO8192QDCx6zgDIfA0BdTRkibQ-GbNaszQUagbJC75XU-bj-NxE822oP-E4ULSGjum0CTlhZ-jk0inMriKJxunBYdmR6raWc5LdNz9INEYSaWaMhxPBJpG0ywLUZ-EqsxdFhup-EwO-FBXeuRY\" alt=\"SurrealDB\"\/><\/figure>\n\n\n\n<ul><li><strong>Online and offline data sync:<\/strong> SurrealDB also allows for real-time queries. It ensures that client devices are in sync with client applications, end-user devices, and server-side components in real-time.<br><\/li><li><strong>Support for GraphQL and REST APIs:<\/strong> We can query the database with any tool we want, but we have SurrealQL, GraphQL (which is not yet implemented but is on the roadmap), REST, and JSON-RPC over WebSockets support.<br><\/li><li><strong>Highly scalable and distributed in nature:<\/strong> SurrealDB can be run in a standalone, in-memory, or distributed cluster mode. SurrealDB is designed to be highly scalable and available in accordance with its distributed nature, and it is implemented in such a way that it can easily handle multi-table transactions as well as document and record IDs without table locking.<br><\/li><li><strong>Rewritten in Rust:<\/strong> SurrealDB is entirely written in Rust. Rust, as we know, has a small memory footprint and low CPU requirements. As a result, SurrealDB has advanced querying capabilities and can function as a database server that can be hosted in a distributed cluster.<br><\/li><li>A<strong>rchitecture:<\/strong> SurrealDB has a one-of-a-kind architecture that supports or can be configured for single-node (in-memory) and on-disk storage, as a distributed key-value store, and as a distributed (multi-node) cluster.<br><\/li><li>S<strong>upport for multiple different clients and libraries:<\/strong> SurrealDB supports the most popular programming languages, including JavaScript, TypeScript, Rust, Go, and others. To ensure low-latency, lightning-fast query performance, connections to client libraries are made via WebSockets using a binary standard.<br><\/li><li>S<strong>urrealQL:<\/strong> SurrealDB also includes SurrealQL, a SQL-like query language with minor differences and improvements for data manipulation. SurrealQL data querying uses the <em>SELECT<\/em>, <em>UPDATE<\/em>, <em>CREATE<\/em>, and <em>DELETE<\/em> methods or statements, just like regular SQL.<\/li><\/ul>\n\n\n\n<h4>Other Features<\/h4>\n\n\n\n<ul><li>Querying in the SQL style.<\/li><li>Deep fetching with no JOIN.<\/li><li>Transactions with multiple rows and tables.<\/li><li>Indexes with multiple columns and full-text search.<\/li><li>SurrealDB includes a collection of strongly typed data types that can be easily converted from one form to another.<\/li><li>SurrealDB includes built-in methods for working with and managing a wide range of data types and structures by default.<\/li><li>Transactions are used to group statements together.<\/li><\/ul>\n\n\n\n<h2>SurrealDB vs. PostgreSQL<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/GG17ym6i2B0w5VZ5drDng9pxoTsYv0GgZQjUW1y9sQNpx-KpKWZJrmYFoPjWQehvx25Gen06XlkiqklB89azva2_QkCrw9RQPBKGN0C0qx8m1UiIU6fWwf6KAree5UgKkNfPgmME3KqZm6XI48CTF6Y\" alt=\"SurrealDB vs. PostgreSQL\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\"><a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-create-a-rest-api-with-rust-rocket-framework-and-diesel-middleware-with-postgresql-database\/\">PostgreSQL<\/a> and SurrealDB are very similar in nature, but they offer distinct feature sets that are worth investigating. Although both are free and open-source relational DMS, PostgreSQL can be used for commercial and non-commercial projects.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">PostgreSQL has been in active development for over 30 years and is available for all major operating systems, including <a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-launch-and-connect-to-a-macos-instance-on-amazon-ec2-and-access-it-through-a-gui-using-vnc-client\/\">macOS<\/a>, <a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-execute-linux-commands-in-python\/\">Linux<\/a>, Windows, BSD, and Solaris. Many of the applications we use on a daily basis are powered by it. It is also more stable and has been battle-tested over time, making it resilient and highly available for a wide range of mission-critical workloads.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">Despite issues with table and index bloating, PostgreSQL integrates with a wide range of other tools and platforms. It also supports distributed ACID transactions, which modify multiple rows across multiple shards, structured and unstructured data, and online\/offline data synchronization.<\/p>\n\n\n\n<h2>Rocket REST API<\/h2>\n\n\n\n<p class=\"has-text-align-justify\">The <a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-create-a-rest-api-with-rust-rocket-framework-and-diesel-middleware-with-postgresql-database\/\">REST API<\/a> has become the industry standard for connecting and transferring data from one source to another. It provides a set of design guidelines and architectural patterns for creating and deploying web services.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">Rocket is a Rust-based HTTP web framework that prioritizes security, flexibility, and speed. Rocket includes features such as type-safety, reusability, logging, static file serving, and many others that developers can use to create scalable applications with less code.<\/p>\n\n\n\n<h2>Hands-On<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/n5ismDeTGsoKDsyOSANNRCJWrHaKm0EL6aR4TnnYU3LsRHByCroYVMvA4VA4i29um0WSuWrUbaBO5HdoQJrZKTz_6ZXh6_W60Kec_TqzdyfzB502vZftzoQeiROAbH-_wiqMYGhwwomggoCXakGIMXM\" alt=\"SurrealDB\"\/><\/figure>\n\n\n\n<p>The repository for the code used in this blog is at <a href=\"https:\/\/github.com\/workfall\/workfall-surreal-rocket\">https:\/\/github.com\/workfall\/workfall-surreal-rocket<\/a><\/p>\n\n\n\n<h3>Folder Structure<\/h3>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" src=\"https:\/\/lh6.googleusercontent.com\/bAER5hhuAYYQxH-s6lNPCN-gJV_D9pA0nyiGJq6vVHCWTM_gIAebcxjC7V5qwTUYRZci1hc4aZh0ZrtMHSx-mLP9TEuI5AfJgBHvGmLBBeVoPDPq8DDg384WHgT0N6QXvJsDURXavcjx6uP4d5cJCL4\" alt=\"SurrealDB\" width=\"299\" height=\"702\"\/><\/figure>\n\n\n\n<h3>Installations<\/h3>\n\n\n\n<p class=\"has-text-align-justify\">Since this is a Rocket application, you must have <a href=\"https:\/\/www.workfall.com\/learning\/blog\/aws-is-in-love-with-rust-and-you-should-be-too\/\">Rust<\/a> installed, including the rust toolchain which is the manager for Rust compilation tools. For this blog, we shall use the nightly build.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">SurrealDB is built in Rust and therefore integrating with Rust is much simpler, but it supports various libraries in <a href=\"https:\/\/www.workfall.com\/learning\/blog\/testing-the-javascript-code-mocha\/\">JavaScript<\/a>, Deno, and <a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-use-go-modules-for-package-management\/\">Golang<\/a>.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">To create a new Rocket application we use the command <strong>cargo new &lt;application_name&gt;<\/strong> and then add the following to your <strong>Cargo.toml<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/HOdfy0s84TwSklrl4jKuhydAN_Uo9c7slXmulRe_-8DeXGJuv-F4TOEdEFcV5JmRyBEf-uHFahbulOGzjCf3kQ4M_HK5clWD0Z7sR9eBr_Dy_-d3DeEvX4kckWiL7AkTt8pFvKDVmVOt49TOW3kb4wk\" alt=\"SurrealDB\"\/><\/figure>\n\n\n\n<p>This will install <strong>surrealdb<\/strong> and <strong>rocket<\/strong> crates.<\/p>\n\n\n\n<p><strong>App.toml<\/strong>:<\/p>\n\n\n\n<p class=\"has-text-align-justify\">This file holds some variables that we can use throughout our application. Here we shall set our database information.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/W0MaeIzod74iJyo9Ky64m0BQSnCbYzl-XOu0F6fQ_1JykaUu_oH7ouIBz_mkF3YS3s2ahYzYDYPPYBZQk1q0vc6l1E63iI9WmObfZoScRzjizaecw3BjXK3Ahzi89kVwXutcY_j_Jebn7vdDTGhxf5k\" alt=\"SurrealDB\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">SurrealDB uses the <strong>namespace<\/strong>,<strong> database,<\/strong> and<strong> datastore <\/strong>parameters to create a new database instance. The <strong>datastore<\/strong> param has three options, it can either be in memory, a local file system, or a distributed (remote store). In our case will use the local file system hence the <strong>file:\/\/temp.db<\/strong> value.<\/p>\n\n\n\n<p class=\"has-text-align-justify\"><strong>Rocket.toml:<br><\/strong>In this file, we\u2019ll put configs pertaining to the Rocket framework. On the default configs, we shall change the port because apparently <strong>surrealdb<\/strong> crate uses the same port.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/l3y0joVRllCaJRtKA00WDlTX5YxSjbcOYbx5Q5gu5va2xvEdC3mEvDphEojlTUa_aMRgJeBCTzidT3fD0HfkJf7qhbX39z6jZ1AL5y0Iq0fyU_IZ5AVK9K-pp-phhztQ81QykTD_tIMhPrAllgLIaYI\" alt=\"SurrealDB\"\/><\/figure>\n\n\n\n<p><strong>src\/db\/middleware.rs(1):<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">Here we shall create the middleware that initializes the database when Rocket is launched. The rocket uses the <strong>Fairing<\/strong> module to create middleware.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/Ow9N8poWsxMOMpiPetw_TX34gEIssaa2P669l0SEtYq5TjDttbVjFJclGxltLpYXytXaqjfgkHkafTz-IGecyb6wUtZ2R2ETg27_Lt9uEUsbfsW5x1T3pE5bX9CdhNcUOyXDowC_vRi63Vuag9Inqnc\" alt=\"SurrealDB\"\/><\/figure>\n\n\n\n<p><strong>src\/db\/middleware.rs(2):<\/strong><\/p>\n\n\n\n<p>We use the <strong>figment<\/strong> method to extract variables from the <strong>App.toml<\/strong> config file.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/2ERs9cPtSeqQdD_Fb0HAe1bIrtCXa9lZwn8ClygLFYoVa8VcSrXo0sJhVE_577l9PtFbH9yrsCEjHka1566bf-MYPKpgTddZluZJoBF_UCJdw-lPXRzuHosQOq59_L3kT9ViMPcNHk_LqIAziKYwuQY\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>src\/db\/mod.rs:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/qxbSZL7xbi7RVde2j-AZQpZASBJ4U5k_YRuZqObupqg14sURcRAomBL3vL-D9XdG1h_3EvJMsg-ZC_TuBpb2K7PPv3VmCECWWUQNjLn5CbTy7_EcgZT8vIeofekf1hHioHQ3QuHDt_btdo_2coogsMY\" alt=\"\"\/><\/figure>\n\n\n\n<h3>SurrealQL queries<\/h3>\n\n\n\n<p class=\"has-text-align-justify\">Note: SurrealDB has a lot of features including but not limited to numerous powerful Data types with their respective functions, other SurrealQL statements, and operators. Feel free to look at their documentation at <a href=\"https:\/\/surrealdb.com\/\">surrealdb.com<\/a>.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">SurrealDB uses the <strong>&lt;table&gt;:&lt;item_id&gt;<\/strong> syntax to store items in the documents. If the id is not specified, SurrealDB will automatically create a unique id for the item. To create a new record, use the CREATE statement. To update a record, use the INSERT statement as shown in the image below.<\/p>\n\n\n\n<p><strong>src\/main.rs(1):<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/UpaFYqy7GyjirkXk0PqtOb4qj-bJGWD-GZ4DZ8lv4zXjElMaHRcq_hV_aqgFMJJ6tTxGxX9jocsuoLxPctTqa6jLZC-aKZmU4sj2AwNf9ka4dC7w_w5OboVsrO2QOb4iJzvVIJrrSqn9-72j5BCmhd0\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>src\/main.rs(2):<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/3mpJQKsz2XahYerZrThIvDYCglev4l_tfXoqze7cQH-_mEPv-Xx8bxqNh2RaaIIK90A6hhbgqbRfIQm_RkkXzbalIwFuwzipXmDQHkB9kSHTB4b-2ryeX9BPmx7_JcF82aJI9tVZI-MZWS9BfL4GS-4\" alt=\"\"\/><\/figure>\n\n\n\n<h3>API Test<\/h3>\n\n\n\n<p>Create user:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/LdoqxOorU5Ee0u8ZjK3dVmq-3amM04oX1BiMW9FZhMm0wWIwnlxHEvGFmS-Sf5QNAlZ27K1ywlCa2y3ZSMkJpwkQDOA-MgI3vvdnn_pIX2oUyLXM7AufkvrC8vD5UxxgbW-X5vVkQyVemzMdkV1NDHM\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Fetch users:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/xxSlCGpF0z14eJHy7m-hwRUxCNbbSZZx3vSvY0GkoCdsEzTVIasDyawvhwOfl6SCg12-0rPAa9L1uBHL5z4lrrMm171PaXpvm983W-ZaSOGmJ1wqGnmgwf_YU44qXw4Y07tIFZdzN8Etas2PXIfwqTM\" alt=\"\"\/><\/figure>\n\n\n\n<h2>Conclusion<\/h2>\n\n\n\n<p class=\"has-text-align-justify\">In this blog, we learned how to use SurrealDB in a Rust Rocket application and the advantages SurrealDB has over other databases. You can always pick SurrealDB if you need to alleviate any of the problems that you may encounter when architecting with either NoSQL or Relational databases.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">We also looked that just like Redis, SurrealDB can offer an in-memory datastore solution which makes it flexible and fast. We will come up with more such use cases in our upcoming blogs.<\/p>\n\n\n\n<p><strong>Meanwhile\u2026<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">If you are a Rust Lover and want to explore more about the above topics, here are a few of our blogs for your reference:<\/p>\n\n\n\n<ul><li><a href=\"https:\/\/www.workfall.com\/learning\/blog\/aws-is-in-love-with-rust-and-you-should-be-too\/\">AWS is in love with RUST and you should be too!<\/a><\/li><li><a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-migrate-rds-mysql-database-to-rds-postgresql-database-using-aws-database-migration-servicedms\/\">How To Migrate RDS MySQL Database To RDS PostgreSQL Database Using AWS Database Migration Service(DMS)?<\/a><\/li><li><a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-create-a-rest-api-with-rust-rocket-framework-and-diesel-middleware-with-postgresql-database\/\">How to Create a REST API with Rust Rocket Framework and Diesel Middleware with PostgreSQL Database?<\/a><\/li><\/ul>\n\n\n\n<p>Stay tuned to get all the updates about our upcoming blogs on the cloud and the latest technologies.<\/p>\n\n\n\n<p><strong>Keep Exploring -&gt; Keep Learning -&gt; Keep Mastering&nbsp;<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">At <a href=\"https:\/\/www.workfall.com\/\">Workfall<\/a>, we strive to provide the best tech and pay opportunities to kickass coders around the world. If you\u2019re looking to work with global clients, build cutting-edge products, and make big bucks doing so, give it a shot at <a href=\"https:\/\/www.workfall.com\/partner\/\">workfall.com\/partner<\/a> today!<\/p>\n\n\n<style type=\"text\/css\"><\/style><section id='' \n                class='helpie-faq accordions faq-toggle open-first groupSettings-501__enabled' \n                data-collection='' \n                data-pagination='0' \n                data-search='0' \n                data-pagination-enabled='0'\n                role='region'\n                aria-label='FAQ Section'\n                aria-live='polite'><h3 class=\"collection-title\">Frequently Asked Questions:<\/h3><article class=\"accordion \"><div class='helpie-faq-row'><div class='helpie-faq-col helpie-faq-col-12' ><ul><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-2809\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-2809\"\r\n                data-id=\"post-2809\" \r\n                data-item=\"hfaq-post-2809\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q. What is SurrealDB and why should I use it?<\/div><\/div><div id=\"accordion-content-post-2809\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-2809\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">8<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\"><strong>A:<\/strong> SurrealDB is a modern, multi-model database that supports SQL-like queries along with graph and document storage. You should use it because it reduces complexity by combining features of relational and NoSQL databases in one system.<\/span><\/p>\n<\/div><\/li><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-2810\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-2810\"\r\n                data-id=\"post-2810\" \r\n                data-item=\"hfaq-post-2810\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q. How does SurrealDB differ from traditional SQL or NoSQL databases?<\/div><\/div><div id=\"accordion-content-post-2810\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-2810\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">8<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\"><strong>A:<\/strong> Unlike traditional databases, SurrealDB allows schema flexibility, supports advanced querying, and provides graph relationships natively\u2014making it versatile for multiple use cases.<\/span><\/p>\n<\/div><\/li><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-2811\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-2811\"\r\n                data-id=\"post-2811\" \r\n                data-item=\"hfaq-post-2811\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q. Can SurrealDB be integrated with frameworks other than Rocket?<\/div><\/div><div id=\"accordion-content-post-2811\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-2811\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">8<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\"><strong>A:<\/strong> Yes. SurrealDB exposes APIs and supports multiple programming languages, so you can integrate it with frameworks like Actix, Axum, or even non-Rust ecosystems.<\/span><\/p>\n<\/div><\/li><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-2812\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-2812\"\r\n                data-id=\"post-2812\" \r\n                data-item=\"hfaq-post-2812\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q. Is SurrealDB production-ready for large-scale applications?<\/div><\/div><div id=\"accordion-content-post-2812\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-2812\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">8<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\"><strong>A:<\/strong> SurrealDB is still maturing but already used in production by some companies. It\u2019s suitable for projects that need flexibility, though enterprises should test scalability before adopting it fully.<\/span><\/p>\n<\/div><\/li><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-2813\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-2813\"\r\n                data-id=\"post-2813\" \r\n                data-item=\"hfaq-post-2813\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q. What are the key benefits of using Rocket REST API with SurrealDB?<\/div><\/div><div id=\"accordion-content-post-2813\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-2813\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">8<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\"><strong>A:<\/strong> You get type safety, Rust performance, and an easy way to build robust REST APIs while leveraging SurrealDB\u2019s hybrid database capabilities.<\/span><\/p>\n<\/div><\/li><\/ul><\/div><\/div><\/article><\/section>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">8<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span> Databases are essential in web development for organizing data in various forms and shapes (both structured and unstructured). Their ultimate goal is for the stored data to be easily retrievable, updated, queried, and generally administered via a graphical user interface (GUI), dashboard, or even command line interface (CLI). We can use database management systems to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1672,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[288],"tags":[85,372,4,89,27,419,244,221,51,97,360,418,42,6],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Use SurrealDB to Persist Data with Rocket REST API - The Workfall Blog<\/title>\n<meta name=\"description\" content=\"SurrealDB is the next-gen serverless database and we&#039;re excited to share how you can use it to persist data with Rocket REST API!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Use SurrealDB to Persist Data with Rocket REST API - The Workfall Blog\" \/>\n<meta property=\"og:description\" content=\"SurrealDB is the next-gen serverless database and we&#039;re excited to share how you can use it to persist data with Rocket REST API!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/\" \/>\n<meta property=\"og:site_name\" content=\"The Workfall Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/workfall\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-21T11:30:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-22T04:17:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/03\/Cover-Images_Part2-1-2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@workfall\" \/>\n<meta name=\"twitter:site\" content=\"@workfall\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Workfall\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\",\"name\":\"Workfall - Hire #Kickass Coders On Demand\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/\",\"sameAs\":[\"https:\/\/www.instagram.com\/workfall\/\",\"https:\/\/www.linkedin.com\/company\/workfall\/\",\"https:\/\/facebook.com\/workfall\",\"https:\/\/twitter.com\/workfall\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400\",\"contentUrl\":\"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400\",\"width\":400,\"height\":400,\"caption\":\"Workfall - Hire #Kickass Coders On Demand\"},\"image\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#website\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/\",\"name\":\"The Workfall Blog\",\"description\":\"#Tech #Remote #Jobs\",\"publisher\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learning.workfall.com\/learning\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#primaryimage\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/03\/Cover-Images_Part2-1-2.png\",\"contentUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/03\/Cover-Images_Part2-1-2.png\",\"width\":1200,\"height\":628,\"caption\":\"SurrealDB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#webpage\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/\",\"name\":\"Use SurrealDB to Persist Data with Rocket REST API - The Workfall Blog\",\"isPartOf\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#primaryimage\"},\"datePublished\":\"2023-03-21T11:30:46+00:00\",\"dateModified\":\"2025-09-22T04:17:53+00:00\",\"description\":\"SurrealDB is the next-gen serverless database and we're excited to share how you can use it to persist data with Rocket REST API!\",\"breadcrumb\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/learning.workfall.com\/learning\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Use SurrealDB to Persist Data with Rocket REST API\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#webpage\"},\"author\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a\"},\"headline\":\"Use SurrealDB to Persist Data with Rocket REST API\",\"datePublished\":\"2023-03-21T11:30:46+00:00\",\"dateModified\":\"2025-09-22T04:17:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#webpage\"},\"wordCount\":1982,\"publisher\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/03\/Cover-Images_Part2-1-2.png\",\"keywords\":[\"api\",\"backend\",\"Cloud\",\"data\",\"Database\",\"Jamstack\",\"javaScript\",\"NoSQL\",\"postgresql\",\"REST\",\"restapi\",\"Rocket REST API\",\"serverless\",\"workfall\"],\"articleSection\":[\"Backend Development\"],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a\",\"name\":\"Workfall\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png\",\"contentUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png\",\"caption\":\"Workfall\"},\"sameAs\":[\"https:\/\/www.workfall.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Use SurrealDB to Persist Data with Rocket REST API - The Workfall Blog","description":"SurrealDB is the next-gen serverless database and we're excited to share how you can use it to persist data with Rocket REST API!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/","og_locale":"en_US","og_type":"article","og_title":"Use SurrealDB to Persist Data with Rocket REST API - The Workfall Blog","og_description":"SurrealDB is the next-gen serverless database and we're excited to share how you can use it to persist data with Rocket REST API!","og_url":"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/","og_site_name":"The Workfall Blog","article_publisher":"https:\/\/facebook.com\/workfall","article_published_time":"2023-03-21T11:30:46+00:00","article_modified_time":"2025-09-22T04:17:53+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/03\/Cover-Images_Part2-1-2.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_creator":"@workfall","twitter_site":"@workfall","twitter_misc":{"Written by":"Workfall","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization","name":"Workfall - Hire #Kickass Coders On Demand","url":"https:\/\/learning.workfall.com\/learning\/blog\/","sameAs":["https:\/\/www.instagram.com\/workfall\/","https:\/\/www.linkedin.com\/company\/workfall\/","https:\/\/facebook.com\/workfall","https:\/\/twitter.com\/workfall"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400","contentUrl":"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400","width":400,"height":400,"caption":"Workfall - Hire #Kickass Coders On Demand"},"image":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/"}},{"@type":"WebSite","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#website","url":"https:\/\/learning.workfall.com\/learning\/blog\/","name":"The Workfall Blog","description":"#Tech #Remote #Jobs","publisher":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learning.workfall.com\/learning\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#primaryimage","url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/03\/Cover-Images_Part2-1-2.png","contentUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/03\/Cover-Images_Part2-1-2.png","width":1200,"height":628,"caption":"SurrealDB"},{"@type":"WebPage","@id":"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#webpage","url":"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/","name":"Use SurrealDB to Persist Data with Rocket REST API - The Workfall Blog","isPartOf":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#primaryimage"},"datePublished":"2023-03-21T11:30:46+00:00","dateModified":"2025-09-22T04:17:53+00:00","description":"SurrealDB is the next-gen serverless database and we're excited to share how you can use it to persist data with Rocket REST API!","breadcrumb":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/learning.workfall.com\/learning\/blog\/"},{"@type":"ListItem","position":2,"name":"Use SurrealDB to Persist Data with Rocket REST API"}]},{"@type":"Article","@id":"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#article","isPartOf":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#webpage"},"author":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a"},"headline":"Use SurrealDB to Persist Data with Rocket REST API","datePublished":"2023-03-21T11:30:46+00:00","dateModified":"2025-09-22T04:17:53+00:00","mainEntityOfPage":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#webpage"},"wordCount":1982,"publisher":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization"},"image":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/use-surrealdb-to-persist-data-with-rocket-rest-api\/#primaryimage"},"thumbnailUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/03\/Cover-Images_Part2-1-2.png","keywords":["api","backend","Cloud","data","Database","Jamstack","javaScript","NoSQL","postgresql","REST","restapi","Rocket REST API","serverless","workfall"],"articleSection":["Backend Development"],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a","name":"Workfall","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/image\/","url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png","contentUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png","caption":"Workfall"},"sameAs":["https:\/\/www.workfall.com"]}]}},"jetpack_featured_media_url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/03\/Cover-Images_Part2-1-2.png","jetpack-related-posts":[{"id":2453,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-create-rest-api-in-spring-boot-and-perform-crud-operations-with-mysql-database\/","url_meta":{"origin":1671,"position":0},"title":"How to Create Rest API in Spring Boot and Perform CRUD Operations with MySQL Database?","date":"October 3, 2023","format":false,"excerpt":"In this blog, we will cover: What are CRUD Operations?What is Spring Boot?What is MySQL Database?What is REST APIHands-OnConclusion What are CRUD Operations? CRUD represents Create, Read\/Retrieve, Update, and Delete \u2013 fundamental actions on persistent storage, aligned with HTTP methods used in web development and database management: - POST: Establishes\u2026","rel":"","context":"In &quot;Backend Development&quot;","img":{"alt_text":"Create Rest API in Spring Boot and Perform CRUD Operations with MySQL Database","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/10\/Tech-Blogs-Cover-Images_Part3.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1518,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-create-a-rest-api-with-rust-rocket-framework-and-diesel-middleware-with-postgresql-database\/","url_meta":{"origin":1671,"position":1},"title":"How to Create a REST API with Rust Rocket Framework and Diesel Middleware with PostgreSQL Database?","date":"November 22, 2022","format":false,"excerpt":"For many years, C and C++ have been the main low-level programming languages. C and C++ require manual deallocation of memory to prevent memory leaks which are the major cause of security breaches in Software. Rust comes in to offer memory safety and at the same time speed of execution\u2026","rel":"","context":"In &quot;Backend Development&quot;","img":{"alt_text":"How to Create a REST API with Rust Rocket Framework and Diesel Middleware with PostgreSQL Database?","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/11\/Cover-Images_Part2-1-1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1680,"url":"https:\/\/learning.workfall.com\/learning\/blog\/create-a-no-code-graphql-server-using-hasura-and-postgresql\/","url_meta":{"origin":1671,"position":2},"title":"Create a No-code GraphQL Server Using Hasura and PostgreSQL","date":"March 28, 2023","format":false,"excerpt":"To handle CRUD, authorization, and business logic, backend developers frequently need to write several lines of code. All of this code must be tested, debugged, and maintained for the duration of the project. This consumes a significant amount of time that developers could be used to create new features. This\u2026","rel":"","context":"In &quot;Backend Development&quot;","img":{"alt_text":"No-code GraphQL Server Using Hasura and PostgreSQL","src":"https:\/\/i0.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/03\/Cover-Images_Part2-1-3.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":226,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-build-and-deploy-a-mern-stack-application-on-aws\/","url_meta":{"origin":1671,"position":3},"title":"How to build and deploy a MERN Stack Application on AWS?","date":"October 27, 2021","format":false,"excerpt":"Do you have a wonderful product idea that keeps springing into your head? However, not sure which technology or framework to adopt for easier and faster deployment of scalable web applications, you can go for MERN Stack.\u00a0 A MERN Stack is a collection of front-end, back-end, and database components that\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"Build and Deploy a MERN Stack Application on AWS","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/10\/MERN.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":322,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-create-publish-and-maintain-high-scalable-apis-using-aws-api-gateway\/","url_meta":{"origin":1671,"position":4},"title":"How to create, publish and maintain high scalable APIs using AWS API Gateway?","date":"November 1, 2021","format":false,"excerpt":"To access data, business logic, and functionalities from backend services, API can act as an interface! Using API Gateway, we can enable two-way communication in real-time applications. In this blog, we will discuss Amazon API Gateway, its architecture, key concepts, use cases, and features. As part of hands-on, we will\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"AWS API Gatway - Workfall","src":"https:\/\/i1.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/API-Gateway.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2287,"url":"https:\/\/learning.workfall.com\/learning\/blog\/reverse-proxy-mastery-deploying-a-full-stack-application-with-multi-container-docker-and-nginx\/","url_meta":{"origin":1671,"position":5},"title":"Reverse Proxy Mastery: Deploying a Full-Stack Application with Multi-Container Docker and Nginx","date":"May 23, 2023","format":false,"excerpt":"Sometimes, developing a full-stack application is not the end of the journey for a web developer. Let us take a case scenario whereby, you have a backend, a frontend, and also a database. For such a setup, we would like to make it easy to replicate our application in different\u2026","rel":"","context":"In &quot;Frontend Development&quot;","img":{"alt_text":"Reverse Proxy Mastery: Deploying a Full-Stack Application with Multi-Container Docker and Nginx","src":"https:\/\/i0.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/05\/Cover-Images_Part2-1-2.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/1671"}],"collection":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/comments?post=1671"}],"version-history":[{"count":6,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/1671\/revisions"}],"predecessor-version":[{"id":2816,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/1671\/revisions\/2816"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/media\/1672"}],"wp:attachment":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/media?parent=1671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/categories?post=1671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/tags?post=1671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}