From ab42cd7d13eb52abb1ae20f24038c77989e5a48d Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 3 Apr 2022 12:10:45 +0200 Subject: [PATCH 1/8] Doc directory was structured and raw guides were added --- docs/{ => api}/api-client.md | 0 docs/{ => api}/api-glossary.md | 0 docs/{ => api}/api-schema.md | 0 docs/{ => apiDocs}/apidocs-client.md | 0 .../architecture-hyperstack.md | 0 docs/{ => architecture}/architecture-kappa.md | 0 docs/{ => architecture}/architecture-sonar.md | 0 .../architecture-tantivy.md | 0 docs/guides/collections.md | 13 ++++ docs/guides/handleData.md | 15 +++++ docs/guides/runServer.md | 67 +++++++++++++++++++ docs/guides/search.md | 11 +++ sidebars.js | 22 +++--- 13 files changed, 120 insertions(+), 8 deletions(-) rename docs/{ => api}/api-client.md (100%) rename docs/{ => api}/api-glossary.md (100%) rename docs/{ => api}/api-schema.md (100%) rename docs/{ => apiDocs}/apidocs-client.md (100%) rename docs/{ => architecture}/architecture-hyperstack.md (100%) rename docs/{ => architecture}/architecture-kappa.md (100%) rename docs/{ => architecture}/architecture-sonar.md (100%) rename docs/{ => architecture}/architecture-tantivy.md (100%) create mode 100644 docs/guides/collections.md create mode 100644 docs/guides/handleData.md create mode 100644 docs/guides/runServer.md create mode 100644 docs/guides/search.md diff --git a/docs/api-client.md b/docs/api/api-client.md similarity index 100% rename from docs/api-client.md rename to docs/api/api-client.md diff --git a/docs/api-glossary.md b/docs/api/api-glossary.md similarity index 100% rename from docs/api-glossary.md rename to docs/api/api-glossary.md diff --git a/docs/api-schema.md b/docs/api/api-schema.md similarity index 100% rename from docs/api-schema.md rename to docs/api/api-schema.md diff --git a/docs/apidocs-client.md b/docs/apiDocs/apidocs-client.md similarity index 100% rename from docs/apidocs-client.md rename to docs/apiDocs/apidocs-client.md diff --git a/docs/architecture-hyperstack.md b/docs/architecture/architecture-hyperstack.md similarity index 100% rename from docs/architecture-hyperstack.md rename to docs/architecture/architecture-hyperstack.md diff --git a/docs/architecture-kappa.md b/docs/architecture/architecture-kappa.md similarity index 100% rename from docs/architecture-kappa.md rename to docs/architecture/architecture-kappa.md diff --git a/docs/architecture-sonar.md b/docs/architecture/architecture-sonar.md similarity index 100% rename from docs/architecture-sonar.md rename to docs/architecture/architecture-sonar.md diff --git a/docs/architecture-tantivy.md b/docs/architecture/architecture-tantivy.md similarity index 100% rename from docs/architecture-tantivy.md rename to docs/architecture/architecture-tantivy.md diff --git a/docs/guides/collections.md b/docs/guides/collections.md new file mode 100644 index 0000000..b391af7 --- /dev/null +++ b/docs/guides/collections.md @@ -0,0 +1,13 @@ +--- +title: Collections +id: collections +--- + + +## local collection by default + +## add a new collection + +## delete a collection + +## share a collection diff --git a/docs/guides/handleData.md b/docs/guides/handleData.md new file mode 100644 index 0000000..bbddf59 --- /dev/null +++ b/docs/guides/handleData.md @@ -0,0 +1,15 @@ +--- +title: handle Data +id: handleData +--- + + +## upload + +## download + +## share + +## block + +## delete \ No newline at end of file diff --git a/docs/guides/runServer.md b/docs/guides/runServer.md new file mode 100644 index 0000000..4e6cefe --- /dev/null +++ b/docs/guides/runServer.md @@ -0,0 +1,67 @@ +--- +title: Run a Server +id: runServer +--- + +The usual setup is that you run sonar-server on localhost and then interact with Sonar through the client, the UI running on http://localhost:9191 or the CLI. The CLI can be invoked with ./sonar from the root of this repository, and is also used to start the server. + +## Installation + +```sh +npm install -g @arsonar/server +sonar help +sonar start +``` + +## Development + +> Note: At the moment [yarn 1](https://classic.yarnpkg.com/) is recommended, please [install it according to the instructions](https://classic.yarnpkg.com/en/docs/install#debian-stable). + +```sh +# clone the sonar repository +git clone https://github.com/arso-project/sonar.git +cd sonar +# install dependencies of all workspaces +yarn +# (re)build the user interface and docs +yarn run rebuild +# when developing on something that uses the ESM version of the +# `@arsonar/client` library: watch and rebuild on changes. +yarn dev:client +``` + +You can start sonar with `./sonar` from the repository root. + +If the start fails with errors related to `sonar-tantivy`, try to redownload or rebuild sonar-tantivy (the search engine included in sonar): + +``` +yarn run build:sonar-tantivy +``` + +If the start fails with errors related to `client`, try to rebuild client : + +``` +yarn run build:client +``` + +```sh +# start the sonar server +./sonar start + +# start the sonar server in dev mode +./sonar start --dev + +``` + +## Running the examples + +This repo includes a few examples. To run them locally, do the following: + +```sh +# build the client library +yarn build:client +# start sonar +./sonar start --disable-authentication --dev +# run the example from the examples/ folder +yarn example react +``` diff --git a/docs/guides/search.md b/docs/guides/search.md new file mode 100644 index 0000000..4943075 --- /dev/null +++ b/docs/guides/search.md @@ -0,0 +1,11 @@ +--- +title: Search +id: search +--- + + +## search or files + +## search for Collections + +## search with params \ No newline at end of file diff --git a/sidebars.js b/sidebars.js index 999b4c1..12e2098 100644 --- a/sidebars.js +++ b/sidebars.js @@ -3,19 +3,25 @@ module.exports = { 'Getting started': [ 'intro-start' ], + Guides: [ + 'guides/runServer', + 'guides/collections', + 'guides/handleData', + 'guides/search' + ], Architecture: [ - 'hyperstack', - 'kappa', - 'tantivy', - 'architecture-sonar' + 'architecture/hyperstack', + 'architecture/kappa', + 'architecture/tantivy', + 'architecture/architecture-sonar' ], 'API docs': [ - 'apidocs-client' + 'apiDocs/apidocs-client' ], API: [ - 'api-client', - 'api-schema', - 'api-glossary' + 'api/api-client', + 'api/api-schema', + 'api/api-glossary' ] } } From 5b9c05958c9afb56c257c162e9fa536eb2d33c7b Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 3 Apr 2022 14:14:05 +0200 Subject: [PATCH 2/8] add some content --- docs/guides/collections.md | 61 ++++++++++++++++++++++++++++++++++++-- docs/guides/filesystem.md | 9 ++++++ docs/guides/handleData.md | 11 ++++++- docs/guides/runServer.md | 8 ++--- docs/guides/search.md | 15 ++++++++-- docs/guides/workspace.md | 29 ++++++++++++++++++ sidebars.js | 2 ++ 7 files changed, 124 insertions(+), 11 deletions(-) create mode 100644 docs/guides/filesystem.md create mode 100644 docs/guides/workspace.md diff --git a/docs/guides/collections.md b/docs/guides/collections.md index b391af7..44fddf5 100644 --- a/docs/guides/collections.md +++ b/docs/guides/collections.md @@ -3,11 +3,66 @@ title: Collections id: collections --- +## What is a Collection +An collection is a set of feeds that are shared among peers. +A feed is an append-only log of records. Each feed is only writable from a single device. +A record is a unit of data. Each record has a type, a ref and a value. -## local collection by default +When sonar is started a local collection is available by default. -## add a new collection +Collections sind einem Workspace zugeordnet. + + +## add or open collection + +To add a new collection to the workspace we simply call the ``createCollection()``` function to open it we use ``openCollection()``` as for example in this code snippet: + + +```js +/** + * Check if the collection already exists if not create a new collection + * @returns opened || new collection + */ +export async function Collection(): Promise { + if (!collection) { + try { + collection = await workspace.openCollection(collectionName) + } catch (err: any) { + collection = await workspace.createCollection(collectionName) + } + // console.log('opened collection', collection.key.toString('hex')) + await ensureSchema(collection, schema) + } + return collection +} +``` ## delete a collection +???? + +## getters + +Various getters are available to retrieve the parameters of the collection: + -## share a collection +```js + get name () { + if (this._info) return this._info.name + return this._nameOrKey + } + get key () { + return this._info && this._info.key + } + get localKey () { + return this._info && this._info.localKey + } + get info () { + return this._info + } + get id () { + return this._info && this._info.id + } + get length () { + return this._length || this._info.length || 0 + } +``` diff --git a/docs/guides/filesystem.md b/docs/guides/filesystem.md new file mode 100644 index 0000000..1aacf28 --- /dev/null +++ b/docs/guides/filesystem.md @@ -0,0 +1,9 @@ +--- +title: Filesystem +id: filesystem +--- + +In order to add files to our collection we need a tile system to manage this. + +Dieses erlaubt uns nun Dateien anzulegen zu lesen oder die entsprechenden Metadaten abzurufen. Weitere Infos unter [FS](https://sonar-apidocs.dev.arso.xyz/fs.js.html) +... \ No newline at end of file diff --git a/docs/guides/handleData.md b/docs/guides/handleData.md index bbddf59..09dc3d6 100644 --- a/docs/guides/handleData.md +++ b/docs/guides/handleData.md @@ -3,6 +3,7 @@ title: handle Data id: handleData --- +# Files ## upload @@ -12,4 +13,12 @@ id: handleData ## block -## delete \ No newline at end of file +## delete + +# Schema + +# Feeds + +# Streams + +..... \ No newline at end of file diff --git a/docs/guides/runServer.md b/docs/guides/runServer.md index 4e6cefe..6357e73 100644 --- a/docs/guides/runServer.md +++ b/docs/guides/runServer.md @@ -7,7 +7,7 @@ The usual setup is that you run sonar-server on localhost and then interact with ## Installation -```sh +```bash npm install -g @arsonar/server sonar help sonar start @@ -17,7 +17,7 @@ sonar start > Note: At the moment [yarn 1](https://classic.yarnpkg.com/) is recommended, please [install it according to the instructions](https://classic.yarnpkg.com/en/docs/install#debian-stable). -```sh +```bash # clone the sonar repository git clone https://github.com/arso-project/sonar.git cd sonar @@ -44,7 +44,7 @@ If the start fails with errors related to `client`, try to rebuild client : yarn run build:client ``` -```sh +```bash # start the sonar server ./sonar start @@ -57,7 +57,7 @@ yarn run build:client This repo includes a few examples. To run them locally, do the following: -```sh +```bash # build the client library yarn build:client # start sonar diff --git a/docs/guides/search.md b/docs/guides/search.md index 4943075..ca3b1e6 100644 --- a/docs/guides/search.md +++ b/docs/guides/search.md @@ -3,9 +3,18 @@ title: Search id: search --- +To search the records of a collection we can issue a query which returns an array with the matching records. -## search or files +```js +(async) query(name, args, optsopt) → {Promise.>} +``` -## search for Collections +The arguments for the query. Depends on the query being used. For records: `{ schema, name, id }` For history: `{ from: timestamp, to: timestamp }` For search: Either a "string" for a simple full-text search, or a tantivy query object. For indexes: `{ schema, prop, value, from, to, reverse, limit }` (to be documented) For relations: `{ subject, object, predicate }` where subject and object are ids and predicate is type #field -## search with params \ No newline at end of file +Here is a small example from our peerBooks App which will return the records for the schema Book: + +```js + const records = await collection.query('records', { + type: 'sonar-peerBooks/Book' + }) +``` \ No newline at end of file diff --git a/docs/guides/workspace.md b/docs/guides/workspace.md new file mode 100644 index 0000000..ca2e11f --- /dev/null +++ b/docs/guides/workspace.md @@ -0,0 +1,29 @@ +--- +title: Workspace +id: workspace +--- +If you start Sonar it comes with a Default Workspace + +When you start Sonar it provides a default workspace. Workspaces are our endpoints in which collections can be managed, more about this under the point Collections. + +There can be multiple workspaces on one Sonar server. + +To create a new workspace you have to pass token and URL of the server for example like this in JavaScript: + +```js +/** + * Get the URL and access token for + * the Sonar instance running in the background. + */ +const url = process.env.SONAR_URL || 'http://localhost:9191/api/v1/default' +const token = process.env.SONAR_TOKEN +/** + * Initializing a client + */ +export const workspace = new Workspace({ + url, + accessCode: token +}); +``` + +Now you can create, update, open and display collections on the workspace. Furthermore the workspace offers the possibility to manage the login of the client. More about the workspace can be found in the API description: [Workspace](https://sonar-apidocs.dev.arso.xyz/Workspace.html) \ No newline at end of file diff --git a/sidebars.js b/sidebars.js index 12e2098..63fbf58 100644 --- a/sidebars.js +++ b/sidebars.js @@ -5,6 +5,8 @@ module.exports = { ], Guides: [ 'guides/runServer', + 'guides/workspace', + 'guides/filesystem', 'guides/collections', 'guides/handleData', 'guides/search' From 0302faac855c6bd2b54a036cff00e13b45f73a60 Mon Sep 17 00:00:00 2001 From: n3m1 Date: Thu, 7 Apr 2022 23:41:40 +0200 Subject: [PATCH 3/8] add some stuff about records +little fixes at the rest --- docs/guides/collections.md | 21 ++++++++++++--- docs/guides/fileRecord.md | 15 +++++++++++ docs/guides/filesystem.md | 9 ------- docs/guides/handleData.md | 24 ----------------- docs/guides/schemaRecord.md | 53 +++++++++++++++++++++++++++++++++++++ docs/guides/search.md | 2 +- docs/guides/workspace.md | 13 ++++++--- sidebars.js | 4 +-- 8 files changed, 99 insertions(+), 42 deletions(-) create mode 100644 docs/guides/fileRecord.md delete mode 100644 docs/guides/filesystem.md delete mode 100644 docs/guides/handleData.md create mode 100644 docs/guides/schemaRecord.md diff --git a/docs/guides/collections.md b/docs/guides/collections.md index 44fddf5..477e5b3 100644 --- a/docs/guides/collections.md +++ b/docs/guides/collections.md @@ -10,7 +10,7 @@ A record is a unit of data. Each record has a type, a ref and a value. When sonar is started a local collection is available by default. -Collections sind einem Workspace zugeordnet. +Collections are assigned to a workspace. You can learn how to create a workspace in the workspace guide.. ## add or open collection @@ -38,9 +38,20 @@ export async function Collection(): Promise { ``` ## delete a collection -???? +Currently it is not possible to delete a collection, maybe we will enable this in the future. -## getters +## list collections and get further informations + + +To list the collections in a workspace and get more information about them you can use the following functions: + +``` js +await workspace.listCollections +collection.key +collection.info +``` + +### getters Various getters are available to retrieve the parameters of the collection: @@ -66,3 +77,7 @@ Various getters are available to retrieve the parameters of the collection: return this._length || this._info.length || 0 } ``` + +## more about collections + +Collections manage our feeds these can have different forms on the one hand you can add simple files to the collections so called `file records` on the other hand you can also manage your databases in a collection with the so called `record scheme`. Furthermore you can share your feeds with others or replicate them, more about this in the corresponding guides. \ No newline at end of file diff --git a/docs/guides/fileRecord.md b/docs/guides/fileRecord.md new file mode 100644 index 0000000..1f22f41 --- /dev/null +++ b/docs/guides/fileRecord.md @@ -0,0 +1,15 @@ +--- +title: file record +id: fileRecord +--- + +To manage files in collections and their feeds there is a predefined scheme and some helper methods which allow us to access or create them in an easy way. + +``` js +await collection.fs.readFile(refOrPath) +await collection.fs.writeFile(refOrPath) +await collection.fs.createReadStream(refOrPath) +await collection.fs.createWriteStream(refOrPath) +await collection.fs.statFile(refOrPath) +await collection.fs.resolveURL(refOrPath) +``` \ No newline at end of file diff --git a/docs/guides/filesystem.md b/docs/guides/filesystem.md deleted file mode 100644 index 1aacf28..0000000 --- a/docs/guides/filesystem.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: Filesystem -id: filesystem ---- - -In order to add files to our collection we need a tile system to manage this. - -Dieses erlaubt uns nun Dateien anzulegen zu lesen oder die entsprechenden Metadaten abzurufen. Weitere Infos unter [FS](https://sonar-apidocs.dev.arso.xyz/fs.js.html) -... \ No newline at end of file diff --git a/docs/guides/handleData.md b/docs/guides/handleData.md deleted file mode 100644 index 09dc3d6..0000000 --- a/docs/guides/handleData.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -title: handle Data -id: handleData ---- - -# Files - -## upload - -## download - -## share - -## block - -## delete - -# Schema - -# Feeds - -# Streams - -..... \ No newline at end of file diff --git a/docs/guides/schemaRecord.md b/docs/guides/schemaRecord.md new file mode 100644 index 0000000..575271e --- /dev/null +++ b/docs/guides/schemaRecord.md @@ -0,0 +1,53 @@ +--- +title: schema record +id: schemaRecord +--- +Since we understand sonar as a p2p database you can freely define a schema in which you can store your information. +the schema has at least one fixed parameters ``` js type: string \\One of the Sonar field types ``` + +A typical scheme looks like this and more can be found at https://sonar.dev.arso.xyz/docs/api-schema: + +``` JSON +const spec = { + title: 'Notes', + fields: { + title: { + type: 'string', + title: 'Title', + index: { + search: { title: true } + } + }, + body: { + type: 'text' + title: 'Body', + index: { + // This could also be the default by field type + search: { bodytext: true } + } + }, + date: { + type: 'date', + title: 'Date', + index: { + basic: true, + search: { facet: true } + } + }, + tags: { + type: 'string', + multiple: true, + title: 'Tags', + index: { + basic: true, + search: { facet: true } + } + }, + author: { + type: 'relation', + title: 'Author' + } + + } +} +``` \ No newline at end of file diff --git a/docs/guides/search.md b/docs/guides/search.md index ca3b1e6..c3af7d2 100644 --- a/docs/guides/search.md +++ b/docs/guides/search.md @@ -6,7 +6,7 @@ id: search To search the records of a collection we can issue a query which returns an array with the matching records. ```js -(async) query(name, args, optsopt) → {Promise.>} +await collection.query(name, args, opts) ``` The arguments for the query. Depends on the query being used. For records: `{ schema, name, id }` For history: `{ from: timestamp, to: timestamp }` For search: Either a "string" for a simple full-text search, or a tantivy query object. For indexes: `{ schema, prop, value, from, to, reverse, limit }` (to be documented) For relations: `{ subject, object, predicate }` where subject and object are ids and predicate is type #field diff --git a/docs/guides/workspace.md b/docs/guides/workspace.md index ca2e11f..eb4496a 100644 --- a/docs/guides/workspace.md +++ b/docs/guides/workspace.md @@ -6,11 +6,16 @@ If you start Sonar it comes with a Default Workspace When you start Sonar it provides a default workspace. Workspaces are our endpoints in which collections can be managed, more about this under the point Collections. -There can be multiple workspaces on one Sonar server. +There can be multiple workspaces on one Sonar server but in alpha state you should use only the default workspace. -To create a new workspace you have to pass token and URL of the server for example like this in JavaScript: +To use the workspace it must be added to the project: + +```npm install @arso-project/sonar-client``` + +Afterwards this can be impoted and created via the constructor: ```js +import { Workspace } from "@arsonar/client"; /** * Get the URL and access token for * the Sonar instance running in the background. @@ -26,4 +31,6 @@ export const workspace = new Workspace({ }); ``` -Now you can create, update, open and display collections on the workspace. Furthermore the workspace offers the possibility to manage the login of the client. More about the workspace can be found in the API description: [Workspace](https://sonar-apidocs.dev.arso.xyz/Workspace.html) \ No newline at end of file +Now you can create, update, open and display collections on the workspace. Furthermore the workspace offers the possibility to manage the login of the client. More about the workspace can be found in the API description: [Workspace](https://sonar-apidocs.dev.arso.xyz/Workspace.html) + +How to create collections and so on you can find in the collection guide. \ No newline at end of file diff --git a/sidebars.js b/sidebars.js index 63fbf58..8f6348e 100644 --- a/sidebars.js +++ b/sidebars.js @@ -6,9 +6,9 @@ module.exports = { Guides: [ 'guides/runServer', 'guides/workspace', - 'guides/filesystem', 'guides/collections', - 'guides/handleData', + 'guides/fileRecord', + 'guides/schemaRecord', 'guides/search' ], Architecture: [ From 53302f03f67a0974f27db7aa6e36e2095cc828f2 Mon Sep 17 00:00:00 2001 From: n3m1 Date: Mon, 11 Apr 2022 12:15:22 +0200 Subject: [PATCH 4/8] records added, corrected typo --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b2d6de3..69b1d40 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + From 2a6b0d8ecd2fd0ce47cb667e9224b1dda3dc1bbb Mon Sep 17 00:00:00 2001 From: n3m1 Date: Mon, 11 Apr 2022 12:41:47 +0200 Subject: [PATCH 5/8] not sure if this is corrcect --- docs/guides/feeds.md | 11 +++++++++++ docs/guides/fileRecord.md | 4 +++- docs/guides/sharing.md | 13 +++++++++++++ sidebars.js | 2 ++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 docs/guides/feeds.md create mode 100644 docs/guides/sharing.md diff --git a/docs/guides/feeds.md b/docs/guides/feeds.md new file mode 100644 index 0000000..871bb3b --- /dev/null +++ b/docs/guides/feeds.md @@ -0,0 +1,11 @@ +--- +title: feeds +id: feeds +--- + +Sonar uses feeds within the collections to manage the records. + +``` js +// Collection: Feeds +await collection.addFeed() +``` \ No newline at end of file diff --git a/docs/guides/fileRecord.md b/docs/guides/fileRecord.md index 1f22f41..56eb97a 100644 --- a/docs/guides/fileRecord.md +++ b/docs/guides/fileRecord.md @@ -12,4 +12,6 @@ await collection.fs.createReadStream(refOrPath) await collection.fs.createWriteStream(refOrPath) await collection.fs.statFile(refOrPath) await collection.fs.resolveURL(refOrPath) -``` \ No newline at end of file +``` + +Currently it is not possible to delete a records for real. When a record is deleted, it receives a tombstone to show other peers that it is no longer available. \ No newline at end of file diff --git a/docs/guides/sharing.md b/docs/guides/sharing.md new file mode 100644 index 0000000..792e6c7 --- /dev/null +++ b/docs/guides/sharing.md @@ -0,0 +1,13 @@ +--- +title: sharing +id: sharing +--- + +If you know the key of a collection you can add it by using the subscribe mechanism. + +This will fetch all records from the first to the last and then waits for new records. Currently only intended for usage in bots (not in short-running Browser clients). + +``` js +// Collection: Subscriptions +await collection.subscribe(name, opts, callback) +``` \ No newline at end of file diff --git a/sidebars.js b/sidebars.js index 8f6348e..8897aca 100644 --- a/sidebars.js +++ b/sidebars.js @@ -7,8 +7,10 @@ module.exports = { 'guides/runServer', 'guides/workspace', 'guides/collections', + 'guides/feeds', 'guides/fileRecord', 'guides/schemaRecord', + 'guides/sharing', 'guides/search' ], Architecture: [ From 31cdf724103d0f47cf47d91ed5db5a7ef8db1197 Mon Sep 17 00:00:00 2001 From: n3m1 Date: Mon, 11 Apr 2022 12:50:39 +0200 Subject: [PATCH 6/8] fixed typo --- docs/guides/collections.md | 2 +- docs/guides/fileRecord.md | 2 +- docs/guides/runServer.md | 2 +- docs/guides/schemaRecord.md | 2 +- docs/guides/search.md | 2 +- docs/guides/workspace.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/guides/collections.md b/docs/guides/collections.md index 477e5b3..e23bb84 100644 --- a/docs/guides/collections.md +++ b/docs/guides/collections.md @@ -1,5 +1,5 @@ --- -title: Collections +title: collections id: collections --- diff --git a/docs/guides/fileRecord.md b/docs/guides/fileRecord.md index 56eb97a..aff93dc 100644 --- a/docs/guides/fileRecord.md +++ b/docs/guides/fileRecord.md @@ -1,5 +1,5 @@ --- -title: file record +title: file records id: fileRecord --- diff --git a/docs/guides/runServer.md b/docs/guides/runServer.md index 6357e73..a645501 100644 --- a/docs/guides/runServer.md +++ b/docs/guides/runServer.md @@ -1,5 +1,5 @@ --- -title: Run a Server +title: runing a server id: runServer --- diff --git a/docs/guides/schemaRecord.md b/docs/guides/schemaRecord.md index 575271e..5318362 100644 --- a/docs/guides/schemaRecord.md +++ b/docs/guides/schemaRecord.md @@ -1,5 +1,5 @@ --- -title: schema record +title: schema records id: schemaRecord --- Since we understand sonar as a p2p database you can freely define a schema in which you can store your information. diff --git a/docs/guides/search.md b/docs/guides/search.md index c3af7d2..b7d2df0 100644 --- a/docs/guides/search.md +++ b/docs/guides/search.md @@ -1,5 +1,5 @@ --- -title: Search +title: searching id: search --- diff --git a/docs/guides/workspace.md b/docs/guides/workspace.md index eb4496a..ecd964d 100644 --- a/docs/guides/workspace.md +++ b/docs/guides/workspace.md @@ -1,5 +1,5 @@ --- -title: Workspace +title: workspaces id: workspace --- If you start Sonar it comes with a Default Workspace From 6ef8e69fe4bbe9c71b9f247f7d4036d455cdec07 Mon Sep 17 00:00:00 2001 From: n3m1 Date: Thu, 14 Apr 2022 14:38:58 +0200 Subject: [PATCH 7/8] fixed typo --- docs/guides/runServer.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/runServer.md b/docs/guides/runServer.md index a645501..eba2b95 100644 --- a/docs/guides/runServer.md +++ b/docs/guides/runServer.md @@ -1,5 +1,5 @@ --- -title: runing a server +title: running a server id: runServer --- From 4ace5e85ff0fa6ef4eb55e2133ad5d9e5245a7d5 Mon Sep 17 00:00:00 2001 From: nemi1012 Date: Thu, 21 Apr 2022 09:52:39 +0200 Subject: [PATCH 8/8] updated some functions --- docs/guides/collections.md | 6 +++++- docs/guides/feeds.md | 2 +- docs/guides/fileRecord.md | 8 +++----- docs/guides/schemaRecord.md | 8 ++++++++ docs/guides/sharing.md | 6 ++++++ 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/docs/guides/collections.md b/docs/guides/collections.md index e23bb84..99d837a 100644 --- a/docs/guides/collections.md +++ b/docs/guides/collections.md @@ -15,7 +15,7 @@ Collections are assigned to a workspace. You can learn how to create a workspace ## add or open collection -To add a new collection to the workspace we simply call the ``createCollection()``` function to open it we use ``openCollection()``` as for example in this code snippet: +To add a new collection to the workspace we simply call the ```createCollection()``` function to open it we use ```openCollection()``` as for example in this code snippet: ```js @@ -78,6 +78,10 @@ Various getters are available to retrieve the parameters of the collection: } ``` +## update a collection + +To update a collection configuration you can use ```updateCollection(name, info)``` + ## more about collections Collections manage our feeds these can have different forms on the one hand you can add simple files to the collections so called `file records` on the other hand you can also manage your databases in a collection with the so called `record scheme`. Furthermore you can share your feeds with others or replicate them, more about this in the corresponding guides. \ No newline at end of file diff --git a/docs/guides/feeds.md b/docs/guides/feeds.md index 871bb3b..380dc9a 100644 --- a/docs/guides/feeds.md +++ b/docs/guides/feeds.md @@ -7,5 +7,5 @@ Sonar uses feeds within the collections to manage the records. ``` js // Collection: Feeds -await collection.addFeed() +await collection.putFeed() ``` \ No newline at end of file diff --git a/docs/guides/fileRecord.md b/docs/guides/fileRecord.md index aff93dc..3d8e8dc 100644 --- a/docs/guides/fileRecord.md +++ b/docs/guides/fileRecord.md @@ -7,11 +7,9 @@ To manage files in collections and their feeds there is a predefined scheme and ``` js await collection.fs.readFile(refOrPath) -await collection.fs.writeFile(refOrPath) -await collection.fs.createReadStream(refOrPath) -await collection.fs.createWriteStream(refOrPath) -await collection.fs.statFile(refOrPath) -await collection.fs.resolveURL(refOrPath) +await collection.fs.createFile(refOrPath) +await collection.fs.updateFile(refOrPath) +await collection.fs.getFileMetadata(refOrPath) ``` Currently it is not possible to delete a records for real. When a record is deleted, it receives a tombstone to show other peers that it is no longer available. \ No newline at end of file diff --git a/docs/guides/schemaRecord.md b/docs/guides/schemaRecord.md index 5318362..51e6157 100644 --- a/docs/guides/schemaRecord.md +++ b/docs/guides/schemaRecord.md @@ -50,4 +50,12 @@ const spec = { } } +``` + +## add new schema + +To add a new schema to a collection you need the function: + +``` js +await collection.putType(schema) ``` \ No newline at end of file diff --git a/docs/guides/sharing.md b/docs/guides/sharing.md index 792e6c7..c232190 100644 --- a/docs/guides/sharing.md +++ b/docs/guides/sharing.md @@ -2,6 +2,12 @@ title: sharing id: sharing --- +With the function ```putFeeds()``` you can add feeds from other collections, which allows you to share them. + +``` js +// Collection: Feeds +await collection.putFeed() +``` If you know the key of a collection you can add it by using the subscribe mechanism.