Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aurel
jio
Commits
212bec60
Commit
212bec60
authored
Nov 26, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs: syntax highlight README.md
parent
0e131159
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
193 additions
and
179 deletions
+193
-179
README.md
README.md
+193
-179
No files found.
README.md
View file @
212bec60
...
@@ -9,25 +9,29 @@ To setup you should jIO include jio.js, dependencies and the connectors for the
...
@@ -9,25 +9,29 @@ To setup you should jIO include jio.js, dependencies and the connectors for the
you want to use in the HTML page header (note that more dependencies may be required
you want to use in the HTML page header (note that more dependencies may be required
depending on type of storages being used):
depending on type of storages being used):
<!-- jio + dependency -->
```
html
<script src="sha256.amd.js"></script>
<!-- jio + dependency -->
<script src="rsvp-custom.js"></script>
<script
src=
"sha256.amd.js"
></script>
<script src="jio.js"></script>
<script
src=
"rsvp-custom.js"
></script>
<script
src=
"jio.js"
></script>
<!-- jio storage libraries -->
<!-- jio storage libraries -->
<script src="complex-queries.js"></script>
<script
src=
"complex-queries.js"
></script>
<script src="localstorage.js"></script>
<script
src=
"localstorage.js"
></script>
<script ...>
<script
...
>
```
Then create your jIO instance like this:
Then create your jIO instance like this:
// create a new jio (type = localStorage)
```
javascript
var jio_instance = jIO.createJIO({
// create a new jio (type = localStorage)
"type": "local",
var
jio_instance
=
jIO
.
createJIO
({
"username": "your_username",
"
type
"
:
"
local
"
,
"application_name": "your_application_name"
"
username
"
:
"
your_username
"
,
});
"
application_name
"
:
"
your_application_name
"
});
```
### Documents and Methods
### Documents and Methods
...
@@ -38,105 +42,107 @@ jIO exposes the following methods to *create*, *read*, *update* and *delete* doc
...
@@ -38,105 +42,107 @@ jIO exposes the following methods to *create*, *read*, *update* and *delete* doc
(for more information, including revision management and available options for
(for more information, including revision management and available options for
each method, please refer to the documentation):
each method, please refer to the documentation):
// create and store new document
```
javascript
jio_instance.post({"title": "some title"}).
// create and store new document
then(function (response) {
jio_instance
.
post
({
"
title
"
:
"
some title
"
}).
// console.log(response);
then
(
function
(
response
)
{
// {
// console.log(response);
// "result": "success",
// {
// "id": "404aef5e-22cc-4a64-a292-37776c6464a3" // Generated id
// "result": "success",
// ...
// "id": "404aef5e-22cc-4a64-a292-37776c6464a3" // Generated id
// }
// ...
});
// }
});
// create or update an existing document
jio_instance.put({"_id": "my_document", "title": "New Title"}).
// create or update an existing document
then(function (response) {
jio_instance
.
put
({
"
_id
"
:
"
my_document
"
,
"
title
"
:
"
New Title
"
}).
// console.log(response);
then
(
function
(
response
)
{
// {
// console.log(response);
// "result": "success",
// {
// "id": "my_document",
// "result": "success",
// ...
// "id": "my_document",
// }
// ...
});
// }
});
// add an attachement to a document
jio_instance.putAttachment({"_id": "my_document", "_attachment": "its_attachment",
// add an attachement to a document
"_data": "abc", "_mimetype": "text/plain"}).
jio_instance
.
putAttachment
({
"
_id
"
:
"
my_document
"
,
"
_attachment
"
:
"
its_attachment
"
,
then(function (response) {
"
_data
"
:
"
abc
"
,
"
_mimetype
"
:
"
text/plain
"
}).
// console.log(response);
then
(
function
(
response
)
{
// {
// console.log(response);
// "result": "success",
// {
// "id": "my_document",
// "result": "success",
// "attachment": "its_attachment"
// "id": "my_document",
// ...
// "attachment": "its_attachment"
// }
// ...
});
// }
});
// read a document
jio_instance.get({"_id": "my_document"}).
// read a document
then(function (response) {
jio_instance
.
get
({
"
_id
"
:
"
my_document
"
}).
// console.log(response);
then
(
function
(
response
)
{
// {
// console.log(response);
// "data": {
// {
// "_id": "my_document",
// "data": {
// "title": "New Title",
// "_id": "my_document",
// "_attachments": {
// "title": "New Title",
// "its_attachment": {
// "_attachments": {
// "length": 3,
// "its_attachment": {
// "digest": "sha256-ba7816bf8f1cfea414140de5dae2223b0361a396177a9cb410ff61f2015ad",
// "length": 3,
// "content_type": "text/plain"
// "digest": "sha256-ba7816bf8f1cfea414140de5dae2223b0361a396177a9cb410ff61f2015ad",
// }
// "content_type": "text/plain"
// }
// }
// },
// }
// ...
// },
// }
// ...
});
// }
});
// read an attachement
jio_instance.getAttachment({"_id": "my_document", "_attachment": "its_attachment"}).
// read an attachement
then(function (response) {
jio_instance
.
getAttachment
({
"
_id
"
:
"
my_document
"
,
"
_attachment
"
:
"
its_attachment
"
}).
// console.log(response);
then
(
function
(
response
)
{
// {
// console.log(response);
// "data": Blob, // contains the attachment data + content type
// {
// ...
// "data": Blob, // contains the attachment data + content type
// }
// ...
});
// }
});
// delete a document and its attachment(s)
jio_instance.remove({"_id": "my_document"}).
// delete a document and its attachment(s)
then(function (response) {
jio_instance
.
remove
({
"
_id
"
:
"
my_document
"
}).
// console.log(response);
then
(
function
(
response
)
{
// {
// console.log(response);
// "result": "success",
// {
// "id": "my_document"
// "result": "success",
// }
// "id": "my_document"
});
// }
});
// delete an attachement
jio_instance.removeAttachment({"_id": "my_document", "_attachment": "its_attachment"}).
// delete an attachement
then(function (response) {
jio_instance
.
removeAttachment
({
"
_id
"
:
"
my_document
"
,
"
_attachment
"
:
"
its_attachment
"
}).
// console.log(response);
then
(
function
(
response
)
{
// {
// console.log(response);
// "result": "success",
// {
// "id": "my_document",
// "result": "success",
// "attachment": "its_attachment"
// "id": "my_document",
// }
// "attachment": "its_attachment"
});
// }
});
// get all documents
jio_instance.allDocs().then(function (response) {
// get all documents
// console.log(response);
jio_instance
.
allDocs
().
then
(
function
(
response
)
{
// {
// console.log(response);
// "data": {
// {
// "total_rows": 1,
// "data": {
// "rows": [{
// "total_rows": 1,
// "id": "my_document",
// "rows": [{
// "value": {}
// "id": "my_document",
// }]
// "value": {}
// }
// }]
// }
// }
});
// }
});
```
### Example
### Example
...
@@ -144,50 +150,52 @@ each method, please refer to the documentation):
...
@@ -144,50 +150,52 @@ each method, please refer to the documentation):
This is an example of how to store a video file with one attachment in local
This is an example of how to store a video file with one attachment in local
storage. Note that attachments should be added after document creation.
storage. Note that attachments should be added after document creation.
// create a new localStorage
```
javascript
var jio_instance = jIO.createJIO({
// create a new localStorage
"type": "local",
var
jio_instance
=
jIO
.
createJIO
({
"username": "user",
"
type
"
:
"
local
"
,
"application_name": "app"
"
username
"
:
"
user
"
,
});
"
application_name
"
:
"
app
"
});
var my_video_blob = new Blob([my_video_binary_string], {
var
my_video_blob
=
new
Blob
([
my_video_binary_string
],
{
"type": "video/ogg"
"
type
"
:
"
video/ogg
"
});
});
// post the document
// post the document
jio_instance.post({
jio_instance
.
post
({
"_id" : "myVideo",
"
_id
"
:
"
myVideo
"
,
"title" : "My Video",
"
title
"
:
"
My Video
"
,
"format" : ["video/ogg", "vorbis", "HD"],
"
format
"
:
[
"
video/ogg
"
,
"
vorbis
"
,
"
HD
"
],
"language" : "en",
"
language
"
:
"
en
"
,
"description" : "Images Compilation"
"
description
"
:
"
Images Compilation
"
}).then(function (response) {
}).
then
(
function
(
response
)
{
// add video attachment
// add video attachment
return jio_instance.putAttachment({
return
jio_instance
.
putAttachment
({
"_id": "myVideo",
"
_id
"
:
"
myVideo
"
,
"_attachment": "video.ogv",
"
_attachment
"
:
"
video.ogv
"
,
"_data": my_video_blob,
"
_data
"
:
my_video_blob
,
});
});
}).then(function (response) {
}).
then
(
function
(
response
)
{
alert('Video Stored');
alert
(
'
Video Stored
'
);
}, function (err) {
},
function
(
err
)
{
if (err.method === "post") {
if
(
err
.
method
===
"
post
"
)
{
alert('Error when posting the document description');
alert
(
'
Error when posting the document description
'
);
} else {
}
else
{
alert('Error when attaching the video');
alert
(
'
Error when attaching the video
'
);
}
}
}, function (progression) {
},
function
(
progression
)
{
console.log(progression);
console
.
log
(
progression
);
});
});
```
### Storage Locations
### Storage Locations
...
@@ -199,20 +207,24 @@ The following storages are currently supported:
...
@@ -199,20 +207,24 @@ The following storages are currently supported:
-
LocalStorage (browser local storage)
-
LocalStorage (browser local storage)
// initialize a local storage
```
javascript
var jio_instance = jIO.createJIO({
// initialize a local storage
"type" : "local",
var
jio_instance
=
jIO
.
createJIO
({
"username" : "me"
"
type
"
:
"
local
"
,
});
"
username
"
:
"
me
"
});
```
-
DAVStorage (connect to webDAV, more information on the
-
DAVStorage (connect to webDAV, more information on the
[
documentation
](
https://www.j-io.org/documentation/jio-documentation/
)
)
[
documentation
](
https://www.j-io.org/documentation/jio-documentation/
)
)
// initialize a webDAV storage (without authentication)
```
javascript
var jio_instance = jIO.createJIO({
// initialize a webDAV storage (without authentication)
"type": "dav",
var
jio_instance
=
jIO
.
createJIO
({
"url": "http://my.dav.srv/uploads"
"
type
"
:
"
dav
"
,
});
"
url
"
:
"
http://my.dav.srv/uploads
"
});
```
<!-- - xWiki storage (connect to xWiki) -->
<!-- - xWiki storage (connect to xWiki) -->
...
@@ -305,28 +317,30 @@ this (note that not all storages support allDocs and complex queries, and
...
@@ -305,28 +317,30 @@ this (note that not all storages support allDocs and complex queries, and
that pre-querying of documents on distant storages should best be done
that pre-querying of documents on distant storages should best be done
server-side):
server-side):
// run allDocs with query option on an existing jIO
```
javascript
jio_instance.allDocs({
// run allDocs with query option on an existing jIO
"query": '(fieldX: >= "string" AND fieldY: < "string")',
jio_instance
.
allDocs
({
// records to display ("from to")
"
query
"
:
'
(fieldX: >= "string" AND fieldY: < "string")
'
,
"limit": [0, 5],
// records to display ("from to")
// sort by
"
limit
"
:
[
0
,
5
],
"sort_on": [[<string A>, 'descending']],
// sort by
// fields to return in response
"
sort_on
"
:
[[
<
string
A
>
,
'
descending
'
]],
"select_list": [<string A>, <string B>]
// fields to return in response
}).then(function (response) {
"
select_list
"
:
[
<
string
A
>
,
<
string
B
>
]
// console.log(response);
}).
then
(
function
(
response
)
{
// {
// console.log(response);
// "total_rows": 1,
// {
// "rows": [{
// "total_rows": 1,
// "id": <string>,
// "rows": [{
// "value": {
// "id": <string>,
// <string A>: <string>,
// "value": {
// <string B>: <string>
// <string A>: <string>,
// }
// <string B>: <string>
// }, { .. }]
// }
// }
// }, { .. }]
});
// }
});
```
To find out more about complex queries, please refer to the documentation.
To find out more about complex queries, please refer to the documentation.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment