mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 23:53:49 +00:00
[Persistence] Move persistence sources
Move persistence sources into a deeper bundle in preparation for splitting of persistence into two bundles - one specific to the Couch adapter, and one for persistence caching generally. This supports WTD-702, the WARP persistence adapter, which will not use Couch for persistence but which will want to use the platform- provided persistence cache.
This commit is contained in:
41
platform/persistence/couch/src/CouchDocument.js
Normal file
41
platform/persistence/couch/src/CouchDocument.js
Normal file
@ -0,0 +1,41 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* A CouchDocument describes domain object model in a format
|
||||
* which is easily read-written to CouchDB. This includes
|
||||
* Couch's _id and _rev fields, as well as a sseparate
|
||||
* metadata field which contains a subset of information found
|
||||
* in the model itself (to support search optimization with
|
||||
* CouchDB views.)
|
||||
* @constructor
|
||||
* @param {string} id the id under which to store this mode
|
||||
* @param {object} model the model to store
|
||||
* @param {string} rev the revision to include (or undefined,
|
||||
* if no revision should be noted for couch)
|
||||
* @param {boolean} whether or not to mark this documnet as
|
||||
* deleted (see CouchDB docs for _deleted)
|
||||
*/
|
||||
function CouchDocument(id, model, rev, markDeleted) {
|
||||
return {
|
||||
"_id": id,
|
||||
"_rev": rev,
|
||||
"_deleted": markDeleted,
|
||||
"metadata": {
|
||||
"category": "domain object",
|
||||
"type": model.type,
|
||||
"owner": "admin",
|
||||
"name": model.name,
|
||||
"created": Date.now()
|
||||
},
|
||||
"model": model
|
||||
};
|
||||
}
|
||||
|
||||
return CouchDocument;
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user