{"id":28414664,"url":"https://github.com/fauna/faunadb","last_synced_at":"2025-06-25T06:32:08.283Z","repository":{"id":291276536,"uuid":"975170233","full_name":"fauna/faunadb","owner":"fauna","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-03T14:45:49.000Z","size":11712,"stargazers_count":50,"open_issues_count":0,"forks_count":10,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-03T19:17:39.219Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fauna.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-29T22:35:34.000Z","updated_at":"2025-06-03T18:33:47.000Z","dependencies_parsed_at":"2025-05-03T15:44:21.201Z","dependency_job_id":null,"html_url":"https://github.com/fauna/faunadb","commit_stats":null,"previous_names":["fauna/faunadb"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fauna/faunadb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fauna%2Ffaunadb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fauna%2Ffaunadb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fauna%2Ffaunadb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fauna%2Ffaunadb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fauna","download_url":"https://codeload.github.com/fauna/faunadb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fauna%2Ffaunadb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261818977,"owners_count":23214405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-03T09:18:52.769Z","updated_at":"2025-06-25T06:32:08.275Z","avatar_url":"https://github.com/fauna.png","language":"Scala","funding_links":[],"categories":["数据库"],"sub_categories":[],"readme":"# Welcome to FaunaDB\n\nFaunaDB is an operational database that combines document flexibility with native relational capabilities, strong consistency, global distribution, ACID transactions, and Internet-native HTTPS connectivity.\n\n# Getting started with development\n\nFaunaDB runs on the JVM and requires a JDK version 17 installed. Fauna uses [sbt](https://www.scala-sbt.org/download/) as its build tool.\n\nFaunaDB is broken out into multiple subprojects primarily found in `ext/`. See the top level [`build.sbt`](build.sbt) file to get oriented on project structure. However the top level project aggregates a number of standard sbt commands\n\n## Basics\n\nBelow are a few FaunaDB-specific sbt examples. See sbt's documention or inspect FaunaDB's sbt configuration to learn more.\n\n**Compile all code and tests:**\n\n```bash\n$ sbt Test/compile\n```\n\n**Run all tests (warning, this will take a while):**\n\n```bash\n$ sbt test\n```\n\nNOTE: Some tests (specifically those in the `multicore` subproject require that multiple loopback IP addresses are available. On macOS, you can configure these with the following command (which last until the next restart):\n\n```bash\n$ for i in {2..16}; do sudo ifconfig lo0 alias 127.0.0.$i up; done\n```\n\n**Run tests in a specific subproject (e.g. `model`):**\n\n```bash\n$ sbt model/test\n```\n\n**Run test Specs which match a specific glob:**\n\n```bash\n$ sbt model/testOnly *DatabaseSpec\n```\n\n**Run a temporary database node for development:**\n\n(Warning, this will reset persisted state every time!)\n\n```bash\n$ sbt runCore\n```\n\n## Building a release\n\nFaunaDB is built as a fat JAR for release purposes, which includes all dependencies in one JAR file. The provisional script `mktarball.sh` will use sbt to build a release JAR and create a tarball with supporting scripts. Once you have built this JAR, see [OPERATING.md](OPERATING.md) for instructions on how to deploy and operate the service.\n\n# Key concepts and features\n\n## Relational model\n\nFauna’s data model integrates the best aspects of document and relational databases. Like other document databases, data is stored in JSON-like documents, allowing for the storage of unstructured data and removing the need for an object-relational mapper (ORM) to translate between objects and tables. Fauna also provides key features of relational databases including strong consistency, first-class support for relationships between documents, and the ability to layer on and enforce schema over time.\n\nDocuments in Fauna are organized into collections, similar to tables in relational databases, providing a familiar structure for data organization. Collections can specify document types, which define and enforce the structure of documents they contain. This feature allows developers to start with a flexible schema and gradually introduce more structure as their application matures. Importantly, Fauna supports relationships between documents in different collections, enabling complex data modeling without duplicating data. This approach combines the ease of use of document databases with the powerful data modeling capabilities of relational systems.\n\n## Fauna Query Language\n\nFauna Query Language (FQL) is a TypeScript-inspired language designed specifically for querying and manipulating data in Fauna. It offers a concise, yet expressive syntax for relational queries, supporting complex joins and data transformations. FQL includes optional static typing to catch errors early in development, improving code quality and reducing runtime issues.\n\nOne of FQL’s powerful features is the ability to create user-defined functions (UDFs). These allow developers to encapsulate complex business logic directly within the database, promoting code reuse and maintaining a clear separation of concerns.\n\nHere’s an example of an FQL query:\n\n``` fql\n// Gets the first customer with\n// an email of \"alice.appleseed@example.com\".\nlet customer = Customer.where(.email == \"alice.appleseed@example.com\")\n                .first()\n\n// Gets the first order for the customer,\n// sorted by descending creation time.\nOrder.where(.customer == customer)\n  .order(desc(.createdAt)).\n  first() {\n    // Project fields from the order.\n    // The order contains fields with document references.\n    // Projecting the fields resolves references,\n    // similar to a SQL join.\n    // `Customer` document reference:\n    customer {\n      name,\n      email\n    },\n    status,\n    createdAt,\n    items {\n      // Nested `Product` document reference:\n      product {\n        name,\n        price,\n        stock,\n        // `Category` document reference:\n        category {\n          name\n        }\n      },\n      quantity\n    },\n    total\n  }\n```\n\nThe query shows how FQL can succinctly express complex operations, including lookups, joins, sorting, and data projection.\n\n## Fauna Schema Language\n\nFauna Schema Language (FSL) allows developers to define and manage database schema as code. It enables version control for schema changes, integration with CI/CD pipelines, and progressive schema enforcement as applications evolve. By treating database schema as code, teams can apply the same rigorous review and testing processes to database changes as they do to application code.\n\nHere’s an example of an FSL schema definition:\n\n``` fsl\ncollection Customer {\n  name: String\n  email: String\n  address: {\n    street: String\n    city: String\n    state: String\n    postalCode: String\n    country: String\n  }\n\n  compute cart: Order? = (customer =\u003e Order.byCustomerAndStatus(customer, 'cart').first())\n\n  // Use a computed field to get the Set of Orders for a customer.\n  compute orders: Set\u003cOrder\u003e = ( customer =\u003e Order.byCustomer(customer))\n\n  // Use a unique constraint to ensure no two customers have the same email.\n  unique [.email]\n\n  index byEmail {\n    terms [.email]\n  }\n}\n```\n\nThis schema defines a Customer collection with specific fields, a computed field, a uniqueness constraint, and an index. The *: Any wildcard constraint allows for arbitrary ad hoc fields, providing flexibility while still enforcing structure where needed.\n\n## Transactions and consistency\n\nIn Fauna, every query is a transaction, ensuring ACID compliance across all operations, even in globally distributed region groups. Fauna’s distributed transaction engine, based on the Calvin protocol, provides strict serializability for all read-write queries and serializable isolation for read-only queries.\n\n## Security and access control\n\nFauna provides comprehensive security features to protect your data and control access. It offers role-based access control (RBAC) for coarse-grained permissions and attribute-based access control (ABAC) for fine-grained, dynamic access rules. This combination allows for highly flexible and precise control over who can access and modify data.\n\nThe system includes built-in user authentication and also supports integration with third-party identity providers, allowing you to use existing authentication systems.\n\n## Change data capture (CDC) and real-time events\n\nFauna’s Change data capture (CDC) feature enables real-time application features. Developers can subscribe to changes in collections or specific documents, receiving either atomic push updates using real-time event streams or on-demand batch pull updates using event feeds. Events are particularly useful for maintaining live application states, building collaborative features that require real-time synchronization, and mirroring changes into external systems.\n\n## Database model\n\nFauna’s database model makes it easy to create databases for isolated environments, such as staging and production, and build secure multi-tenant applications.\n\nFor multi-tenant applications, developers can create isolated child databases for each tenant, applying separate access controls and schema as needed.\n\nThe same approach can be applied to isolated environments, enabling separate databases for each environment, ensuring that changes in one environment do not affect others.\n\nThis model simplifies administration, ensures clear separation between environments, and guarantees that tenants or environments cannot interfere with each other’s data.\n\n# License\n\nFauna is available under license. See LICENSE.md for a copy of the license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffauna%2Ffaunadb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffauna%2Ffaunadb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffauna%2Ffaunadb/lists"}