Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio-main
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Hardik Juneja
jio-main
Commits
315da2d6
Commit
315da2d6
authored
Mar 10, 2015
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MemoryStorage.get now returns attachment list
parent
eab60f05
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
46 deletions
+43
-46
src/jio.storage/memorystorage.js
src/jio.storage/memorystorage.js
+16
-18
test/jio.storage/memorystorage.tests.js
test/jio.storage/memorystorage.tests.js
+27
-28
No files found.
src/jio.storage/memorystorage.js
View file @
315da2d6
...
@@ -33,7 +33,6 @@
...
@@ -33,7 +33,6 @@
this
.
_database
=
{};
this
.
_database
=
{};
}
}
MemoryStorage
.
prototype
.
put
=
function
(
metadata
)
{
MemoryStorage
.
prototype
.
put
=
function
(
metadata
)
{
if
(
!
this
.
_database
.
hasOwnProperty
(
metadata
.
_id
))
{
if
(
!
this
.
_database
.
hasOwnProperty
(
metadata
.
_id
))
{
this
.
_database
[
metadata
.
_id
]
=
{
this
.
_database
[
metadata
.
_id
]
=
{
...
@@ -45,8 +44,13 @@
...
@@ -45,8 +44,13 @@
};
};
MemoryStorage
.
prototype
.
get
=
function
(
param
)
{
MemoryStorage
.
prototype
.
get
=
function
(
param
)
{
var
doc
,
key
,
found
=
false
,
attachments
=
{};
try
{
try
{
return
JSON
.
parse
(
this
.
_database
[
param
.
_id
].
doc
);
doc
=
JSON
.
parse
(
this
.
_database
[
param
.
_id
].
doc
);
}
catch
(
error
)
{
}
catch
(
error
)
{
if
(
error
instanceof
TypeError
)
{
if
(
error
instanceof
TypeError
)
{
throw
new
jIO
.
util
.
jIOError
(
throw
new
jIO
.
util
.
jIOError
(
...
@@ -58,22 +62,16 @@
...
@@ -58,22 +62,16 @@
}
}
// XXX NotImplemented: list all attachments
// XXX NotImplemented: list all attachments
for
(
key
in
this
.
_database
[
param
.
_id
].
attachments
)
{
// var doc = JSON.parse(this._database[param._id].doc),
if
(
this
.
_database
[
param
.
_id
].
attachments
.
hasOwnProperty
(
key
))
{
// key,
found
=
true
;
// found = false,
attachments
[
key
]
=
{};
// attachments = {};
}
//
}
// for (key in this._database[param._id].attachments) {
if
(
found
)
{
// if (this._database[param._id].attachments.hasOwnProperty(key)) {
doc
.
_attachments
=
attachments
;
// found = true;
}
// attachments[key] = {};
return
doc
;
// }
// }
// if (found) {
// doc._attachments = attachments;
// }
// return doc;
};
};
MemoryStorage
.
prototype
.
remove
=
function
(
param
)
{
MemoryStorage
.
prototype
.
remove
=
function
(
param
)
{
...
...
test/jio.storage/memorystorage.tests.js
View file @
315da2d6
...
@@ -155,34 +155,33 @@
...
@@ -155,34 +155,33 @@
});
});
});
});
// test("get document with attachment", function () {
test
(
"
get document with attachment
"
,
function
()
{
// var id = "putattmt1";
var
id
=
"
putattmt1
"
;
//
// this.jio.__storage._database[id] = {
this
.
jio
.
__storage
.
_database
[
id
]
=
{
// "doc": JSON.stringify({}),
"
doc
"
:
JSON
.
stringify
({}),
// "attachments": {
"
attachments
"
:
{
// putattmt2: undefined
putattmt2
:
undefined
// }
}
// };
};
//
// stop();
stop
();
// expect(1);
expect
(
1
);
//
// this.jio.get({"_id": id})
this
.
jio
.
get
({
"
_id
"
:
id
})
// .then(function (result) {
.
then
(
function
(
result
)
{
// deepEqual(result, {
deepEqual
(
result
,
{
// "_id": id,
"
_id
"
:
id
,
// "_attachment": {},
"
_attachments
"
:
{
putattmt2
:
{}}
// "title": "myPost1"
},
"
Check document
"
);
// }, "Check document");
})
// })
.
fail
(
function
(
error
)
{
// .fail(function (error) {
ok
(
false
,
error
);
// ok(false, error);
})
// })
.
always
(
function
()
{
// .always(function () {
start
();
// start();
});
// });
});
// });
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// memoryStorage.remove
// memoryStorage.remove
...
...
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