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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
lucas.parsy
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
Show 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
you want to use in the HTML page header (note that more dependencies may be required
depending on type of storages being used):
<!-- jio + dependency -->
<script src="sha256.amd.js"></script>
<script src="rsvp-custom.js"></script>
<script src="jio.js"></script>
```
html
<!-- jio + dependency -->
<script
src=
"sha256.amd.js"
></script>
<script
src=
"rsvp-custom.js"
></script>
<script
src=
"jio.js"
></script>
<!-- jio storage libraries -->
<script src="complex-queries.js"></script>
<script src="localstorage.js"></script>
<!-- jio storage libraries -->
<script
src=
"complex-queries.js"
></script>
<script
src=
"localstorage.js"
></script>
<script ...>
<script
...
>
```
Then create your jIO instance like this:
// create a new jio (type = localStorage)
var jio_instance = jIO.createJIO({
```
javascript
// create a new jio (type = localStorage)
var
jio_instance
=
jIO
.
createJIO
({
"
type
"
:
"
local
"
,
"
username
"
:
"
your_username
"
,
"
application_name
"
:
"
your_application_name
"
});
});
```
### Documents and Methods
...
...
@@ -38,8 +42,9 @@ jIO exposes the following methods to *create*, *read*, *update* and *delete* doc
(for more information, including revision management and available options for
each method, please refer to the documentation):
// create and store new document
jio_instance.post({"title": "some title"}).
```
javascript
// create and store new document
jio_instance
.
post
({
"
title
"
:
"
some title
"
}).
then
(
function
(
response
)
{
// console.log(response);
// {
...
...
@@ -49,8 +54,8 @@ each method, please refer to the documentation):
// }
});
// create or update an existing document
jio_instance.put({"_id": "my_document", "title": "New Title"}).
// create or update an existing document
jio_instance
.
put
({
"
_id
"
:
"
my_document
"
,
"
title
"
:
"
New Title
"
}).
then
(
function
(
response
)
{
// console.log(response);
// {
...
...
@@ -60,8 +65,8 @@ each method, please refer to the documentation):
// }
});
// add an attachement to a document
jio_instance.putAttachment({"_id": "my_document", "_attachment": "its_attachment",
// add an attachement to a document
jio_instance
.
putAttachment
({
"
_id
"
:
"
my_document
"
,
"
_attachment
"
:
"
its_attachment
"
,
"
_data
"
:
"
abc
"
,
"
_mimetype
"
:
"
text/plain
"
}).
then
(
function
(
response
)
{
// console.log(response);
...
...
@@ -73,8 +78,8 @@ each method, please refer to the documentation):
// }
});
// read a document
jio_instance.get({"_id": "my_document"}).
// read a document
jio_instance
.
get
({
"
_id
"
:
"
my_document
"
}).
then
(
function
(
response
)
{
// console.log(response);
// {
...
...
@@ -93,8 +98,8 @@ each method, please refer to the documentation):
// }
});
// read an attachement
jio_instance.getAttachment({"_id": "my_document", "_attachment": "its_attachment"}).
// read an attachement
jio_instance
.
getAttachment
({
"
_id
"
:
"
my_document
"
,
"
_attachment
"
:
"
its_attachment
"
}).
then
(
function
(
response
)
{
// console.log(response);
// {
...
...
@@ -103,8 +108,8 @@ each method, please refer to the documentation):
// }
});
// delete a document and its attachment(s)
jio_instance.remove({"_id": "my_document"}).
// delete a document and its attachment(s)
jio_instance
.
remove
({
"
_id
"
:
"
my_document
"
}).
then
(
function
(
response
)
{
// console.log(response);
// {
...
...
@@ -113,8 +118,8 @@ each method, please refer to the documentation):
// }
});
// delete an attachement
jio_instance.removeAttachment({"_id": "my_document", "_attachment": "its_attachment"}).
// delete an attachement
jio_instance
.
removeAttachment
({
"
_id
"
:
"
my_document
"
,
"
_attachment
"
:
"
its_attachment
"
}).
then
(
function
(
response
)
{
// console.log(response);
// {
...
...
@@ -124,8 +129,8 @@ each method, please refer to the documentation):
// }
});
// get all documents
jio_instance.allDocs().then(function (response) {
// get all documents
jio_instance
.
allDocs
().
then
(
function
(
response
)
{
// console.log(response);
// {
// "data": {
...
...
@@ -136,7 +141,8 @@ each method, please refer to the documentation):
// }]
// }
// }
});
});
```
### Example
...
...
@@ -144,25 +150,26 @@ each method, please refer to the documentation):
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.
// create a new localStorage
var jio_instance = jIO.createJIO({
```
javascript
// create a new localStorage
var
jio_instance
=
jIO
.
createJIO
({
"
type
"
:
"
local
"
,
"
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
"
});
});
// post the document
jio_instance.post({
// post the document
jio_instance
.
post
({
"
_id
"
:
"
myVideo
"
,
"
title
"
:
"
My Video
"
,
"
format
"
:
[
"
video/ogg
"
,
"
vorbis
"
,
"
HD
"
],
"
language
"
:
"
en
"
,
"
description
"
:
"
Images Compilation
"
}).then(function (response) {
}).
then
(
function
(
response
)
{
// add video attachment
return
jio_instance
.
putAttachment
({
...
...
@@ -171,11 +178,11 @@ storage. Note that attachments should be added after document creation.
"
_data
"
:
my_video_blob
,
});
}).then(function (response) {
}).
then
(
function
(
response
)
{
alert
(
'
Video Stored
'
);
}, function (err) {
},
function
(
err
)
{
if
(
err
.
method
===
"
post
"
)
{
alert
(
'
Error when posting the document description
'
);
...
...
@@ -183,11 +190,12 @@ storage. Note that attachments should be added after document creation.
alert
(
'
Error when attaching the video
'
);
}
}, function (progression) {
},
function
(
progression
)
{
console
.
log
(
progression
);
});
});
```
### Storage Locations
...
...
@@ -199,20 +207,24 @@ The following storages are currently supported:
-
LocalStorage (browser local storage)
// initialize a local storage
var jio_instance = jIO.createJIO({
```
javascript
// initialize a local storage
var
jio_instance
=
jIO
.
createJIO
({
"
type
"
:
"
local
"
,
"
username
"
:
"
me
"
});
});
```
-
DAVStorage (connect to webDAV, more information on the
[
documentation
](
https://www.j-io.org/documentation/jio-documentation/
)
)
// initialize a webDAV storage (without authentication)
var jio_instance = jIO.createJIO({
```
javascript
// initialize a webDAV storage (without authentication)
var
jio_instance
=
jIO
.
createJIO
({
"
type
"
:
"
dav
"
,
"
url
"
:
"
http://my.dav.srv/uploads
"
});
});
```
<!-- - xWiki storage (connect to xWiki) -->
...
...
@@ -305,8 +317,9 @@ this (note that not all storages support allDocs and complex queries, and
that pre-querying of documents on distant storages should best be done
server-side):
// run allDocs with query option on an existing jIO
jio_instance.allDocs({
```
javascript
// run allDocs with query option on an existing jIO
jio_instance
.
allDocs
({
"
query
"
:
'
(fieldX: >= "string" AND fieldY: < "string")
'
,
// records to display ("from to")
"
limit
"
:
[
0
,
5
],
...
...
@@ -314,7 +327,7 @@ server-side):
"
sort_on
"
:
[[
<
string
A
>
,
'
descending
'
]],
// fields to return in response
"
select_list
"
:
[
<
string
A
>
,
<
string
B
>
]
}).then(function (response) {
}).
then
(
function
(
response
)
{
// console.log(response);
// {
// "total_rows": 1,
...
...
@@ -326,7 +339,8 @@ server-side):
// }
// }, { .. }]
// }
});
});
```
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