Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7414030
ve.dm.FakeMongo.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ve.dm.FakeMongo.js
View Options
/*!
* VisualEditor DataModel Fake mongo-like class for testing
*
* @copyright See AUTHORS.txt
*/
// Fake mongo class, with limited query API, that stores a single collection in memory
ve
.
dm
.
FakeMongo
=
function
VeDmFakeMongo
()
{
this
.
storedDataForDoc
=
{};
this
.
dataForDoc
=
undefined
;
this
.
log
=
[];
};
OO
.
initClass
(
ve
.
dm
.
FakeMongo
);
ve
.
dm
.
FakeMongo
.
prototype
.
connect
=
function
()
{
this
.
dataForDoc
=
this
.
storedDataForDoc
;
return
Promise
.
resolve
(
this
);
};
ve
.
dm
.
FakeMongo
.
prototype
.
db
=
function
()
{
return
this
;
};
ve
.
dm
.
FakeMongo
.
prototype
.
collection
=
function
()
{
return
this
;
};
ve
.
dm
.
FakeMongo
.
prototype
.
dropDatabase
=
function
()
{
this
.
storedDataForDoc
=
this
.
dataForDoc
=
{};
return
Promise
.
resolve
();
};
ve
.
dm
.
FakeMongo
.
prototype
.
findOneAndUpdate
=
function
(
search
,
update
)
{
const
docName
=
search
.
docName
;
if
(
!
this
.
dataForDoc
[
docName
]
)
{
this
.
dataForDoc
[
docName
]
=
JSON
.
parse
(
JSON
.
stringify
(
update
.
$setOnInsert
)
);
}
return
Promise
.
resolve
(
{
value
:
JSON
.
parse
(
JSON
.
stringify
(
this
.
dataForDoc
[
docName
]
)
)
}
);
};
ve
.
dm
.
FakeMongo
.
prototype
.
updateOne
=
function
(
search
,
update
)
{
const
docName
=
search
.
docName
,
transactions
=
this
.
dataForDoc
[
docName
].
transactions
,
stores
=
this
.
dataForDoc
[
docName
].
stores
;
transactions
.
push
.
apply
(
transactions
,
update
.
$push
.
transactions
.
$each
);
stores
.
push
.
apply
(
stores
,
update
.
$push
.
stores
.
$each
);
return
Promise
.
resolve
();
};
ve
.
dm
.
FakeMongo
.
prototype
.
close
=
function
()
{
this
.
dataForDoc
=
undefined
;
return
Promise
.
resolve
();
};
ve
.
dm
.
FakeMongo
.
prototype
.
logServerEvent
=
function
(
ob
)
{
this
.
log
.
push
(
ob
);
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 22, 01:22 (1 d, 16 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
91/f0/9ffb9ad75db9d1b568003249310b
Default Alt Text
ve.dm.FakeMongo.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment