5.8k sao GitHub và vẫn tăng — tonsky/datascript là dự án Clojure mà TopGit đang theo dõi trên nền tảng. Immutable database and Datalog query engine for Clojure, ClojureScript and JS
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
What if creating a database would be as cheap as creating a Hashmap?
An immutable in-memory database and Datalog query engine in Clojure and ClojureScript.
DataScript is meant to run inside the browser. It is cheap to create, quick to query and ephemeral. You create a database on page load, put some data in it, track changes, do queries and forget about it when the user closes the page.
DataScript databases are immutable and based on persistent data structures. In fact, they’re more like data structures than databases (think Hashmap). Unlike querying a real SQL DB, when you query DataScript, it all comes down to a Hashmap lookup. Or series of lookups. Or array iteration. There’s no particular overhead to it. You put a little data in it, it’s fast. You put in a lot of data, well, at least it has indexes. That should do better than you filtering an array by hand anyway. The thing is really lightweight.
The intention with DataScript is to be a basic building block in client-side applications that needs to track a lot of state during their lifetime. There’s a lot of benefits:
Central, uniform approach to manage all application state. Clients working with state become decoupled and independent: rendering, server sync, undo/redo do not interfere with each other.
Immutability simplifies things even in a single-threaded browser environment. Keep track of app state evolution, rewind to any point in time, always render consistent state, sync in background without locking anybody.
Datalog query engine to answer non-trivial questions about current app state.
Structured format to track data coming in and out of DB. Datalog queries can be run against it too.
Use strings such as ":db/id", ":db/add", etc. instead of db-namespaced keywords
Use regular JS arrays and objects to pass data to transact and db_with
Transaction reports:
report.tempids has string keys ("-1" for entity tempid -1), use resolve_tempid to set up a correspondence
Check out test/js/tests.js for usage examples.
Project status
Stable. Most of the features done, expecting non-breaking API additions and performance optimizations. No docs at the moment, use examples & Datomic documentation.
The following features are supported:
Database as a value: each DB is an immutable value. New DBs are created on top of old ones, but old ones stay perfectly valid too
Triple store model
EAVT, AEVT and AVET indexes
Multi-valued attributes via :db/cardinality :db.cardinality/many
Lazy entities and :db/valueType :db.type/ref auto-expansion
Database “mutations” via transact!
Callback-based analogue to txReportQueue via listen!
Direct index lookup and iteration via datoms and seek-datoms
Filtered databases via filter
Lookup refs
Unique constraints, upsert
Pull API (thx David Thomas Hume)
Query engine features:
Implicit joins
Query over DB or regular collections
Parameterized queries via :in clause
Tuple, collection, relation binding forms in :in clause
Query over multiple DB/collections
Predicates and user functions in query
Negation and disjunction
Rules, recursive rules
Aggregates
Find specifications
Interface differences:
Conn is just an atom storing last DB value, use @conn instead of (d/db conn)
Instead of #db/id[:db.part/user -100] just use -100 in place of :db/id or entity id
Transactor functions can be called as [:db.fn/call f args] where f is a function reference and will take db as first argument (thx @thegeez)
In ClojureScript, custom query functions and aggregates should be passed as source instead of being referenced by symbol (due to lack of resolve in CLJS)
Custom aggregate functions are called via aggregate keyword: :find (aggregate ?myfn ?e) :in $ ?myfn
Additional :db.fn/retractAttribute shortcut
Transactions are not annotated by default with :db/txInstant
When “transaction function” is called, the db that this function receive is a “partial db” relative to it's position in transaction.
Differences from Datomic
DataScript is built totally from scratch and is not related by any means to the popular Clojure database Datomic
Runs in a browser and/or in a JVM
Simplified schema, not queryable
Attributes do not have to be declared in advance. Put them to schema only when you need special behaviour from them
Any type can be used for values
No :db/ident for attributes, keywords are literally attribute values, no integer id behind them
No schema migrations
No full-text search, no partitions
Aimed at interactive, long-living browser applications, DataScript DBs operate in constant space. If you do not add new entities, just update existing ones, or clean up database from time to time, memory consumption will be limited. This is unlike Datomic which keeps history of all changes, thus grows monotonically. DataScript does not track history by default, but you can do it via your own code if needed.
Some of the features are omitted intentionally. Different apps have different needs in storing/transfering/keeping track of DB state. DataScript is a foundation to build exactly the right storage solution for your needs without selling too much “vision”.
tonsky/datascript có 5.8k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/tonsky/datascript. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
tonsky/datascript có những chủ đề gì?
GitHub topics của tonsky/datascript: "clojure", "clojurescript", "database", "datascript", "memory-database". TopGit xếp repo vào nhóm Data.
tonsky/datascript còn đang phát triển không?
Commit gần nhất trên tonsky/datascript là 1.1 năm trước (theo timestamp GitHub). Repo có 319 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
tonsky/datascript là gì?
tonsky/datascript (tonsky/datascript) là dự án Clojure trên GitHub. Theo mô tả gốc: Immutable database and Datalog query engine for Clojure, ClojureScript and JS
tonsky/datascript so với các dự án Data khác thế nào?
tonsky/datascript được TopGit xếp vào nhóm Data, với 5.8k sao GitHub và viết bằng Clojure. Xem trang chủ đề Data trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
tonsky/datascript viết bằng ngôn ngữ gì?
tonsky/datascript chủ yếu viết bằng Clojure. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Vì sao tonsky/datascript được xếp vào nhóm Data?
TopGit xếp tonsky/datascript vào nhóm Data dựa trên GitHub topics và mô tả của repo (gắn thẻ: "clojure", "clojurescript", "database"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về datascript?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về datascript.