Multi-Layer ORM for Javascript Client+Server
npm install @diaspora/diasporaMulti-source ORM for NodeJS & the browser
Fancy badges:









for integration tests.
To install Diaspora, simply run one of the following commands:
``bash`With NPM
npm install --save @diaspora/diasporaWith Yarn
yarn add @diaspora/diaspora
Welcome on the GitHub repository of Diaspora. Please visit the manual website, where you can find guides, tutorials, or the API tocumentation
> Important note: Diaspora is very young and under heavy development. You
are totally free to use it or contribute, but be aware that some important
features are incomplete or absent:
Relations*: Not implemented
Query language*: Supported up to Specification level 2.
Multi sources*: not tested
| Adapter | Description | Links | Maintainer | Platform | Other infos | |
|---|---|---|---|---|---|---|
| Node | Browser | |||||
In Memory | A simple adapter that stores its data directly in the memory | Built-in | ✓ | ✓ | [QL] v2 | |
WebApi | A customizable adapter that use HTTP APIs as data source. Convinient to query easily REST, SOAP or GraphQL apis. | ✓ | ✓ | |||
WebStorage | A simple adapter that stores its data in the browser's local or session storage. | ✗ | ✓ | |||
MongoDB | ✓ | ✗ | [QL] v2 | |||
Redis | ✓ | ✗ | [QL] v2 | |||
plugin-server: a package to easily create APIs for Diaspora models
Diaspora requires:
* Node >= 6.4.0>=
* Browsers:
* Edge 12>=
* Firefox 18>=
* Chrome 49>=
* Safari & iOS Safari 10>=
* Chrome for Android 61>=
* Samsung Internet 5
More briefly, Diaspora runs on all browsers & JavaScript engines that supports
Proxies.
Notable incompatible browsers are
* Internet Explorer (all versions)
* Opera Mini
* UC Browser for Android
Need help getting started? We have a page on how to get started in 5 minutes.
Here is a short API overview. For a detailed API documentation, check the Diaspora API Documentation
#### spawn([object props]) => Entity
Create an entity, defining its properties with provided props. The returned
entity should be persisted later.
#### spawnMany([object[] props]) => Set
See spawn.
#### insert([object props]) => Promise(Entity)
Create an entity, defining its properties with provided props, and persist it
immediately.
#### insertMany([object[] props]) => Promise(Set)
See insertMany.
#### find(object || Any query, [object options], [string source]) => Promise(Entity)
Retrieve an entity matching query. If query isn't an object, it is
considered as an ID.
#### findMany(object || Any query, [object options], [string source]) => Promise(Set)
See find
#### delete(object || Any query, [object options], [string source]) => Promise(Entity)
Delete an entity matching query. If query isn't an object, it is consideredoptions
as an ID. can contain allowEmptyQuery.
#### deleteMany(object || Any query, [object options], [string source]) => Promise(Entity)
See delete
#### update(object || Any query, object newAttrs, [object options], [string source]) => Promise(Entity)
Update a single entity matching querywith attributes in newAttrs. If queryoptions
isn't an object, it is considered as an ID. can containallowEmptyQuery.
#### updateMany(object || Any query, object newAttrs, [object options], [string source]) => Promise(Set)
See update
#### destroy([string source]) => Promise(this)
Delete this entity from the specified source. Source hash object is set toundefined
#### persist([string source]) => Promise(this)
Save current entity to the specified source.
#### fetch([string source]) => Promise(this)
Reload entity from specified source.
> Manual change of properties
Unsure > Entity may change status to desync ?
> P2P Adapter
Unsure > May be interesting... Check for possible problems about data
modification, etc etc.
> IndexedDB Adapter (browser)
Unsure > IndexedDB technology may be too immature. See MDN about IndexedDB.
Note: Plan to show fallback implementations
[QL]: https://diaspora.ithoughts.io/guides/query-language#match-queries
If you are having issues, or you want to participate to the development and create new features, you may have to use the development or staging version of Diaspora. Here is how you can do that:
`shdevelopClone the repository & go into it
git clone https://github.com/diaspora-orm/diaspora.git && cd diasporaGo on the staging branch (you can also use directly the
branch, but it may be less stable)sudo
git checkout stagingThe following command installs dependencies & compiles the package
npm run buildFinally, expose your local build so that it can be used in other projects.
You may need to run it with
.
npm link
> Note that you may need to re-run
npm link @diaspora/diaspora after every install (npm install`) in your project.