modif Odmdb for search and wwws to improve localdb
This commit is contained in:
@@ -84,23 +84,19 @@ router.get(
|
||||
(req, res) => {
|
||||
const objectPathname = `../../${req.params.tribe}/objects/options/${req.params.optionname}_${req.header.xlang}.json`;
|
||||
if (fs.existsSync(objectPathname)) {
|
||||
res
|
||||
.status(200)
|
||||
.json({
|
||||
status: 200,
|
||||
ref: "Odmdb",
|
||||
msg: "optionfind",
|
||||
data: fs.readJsonSync(objectPathname),
|
||||
});
|
||||
res.status(200).json({
|
||||
status: 200,
|
||||
ref: "Odmdb",
|
||||
msg: "optionfind",
|
||||
data: fs.readJsonSync(objectPathname),
|
||||
});
|
||||
} else {
|
||||
res
|
||||
.status(404)
|
||||
.json({
|
||||
status: 404,
|
||||
ref: "Odmdb",
|
||||
msg: "optionnotfound",
|
||||
data: { objectPathname },
|
||||
});
|
||||
res.status(404).json({
|
||||
status: 404,
|
||||
ref: "Odmdb",
|
||||
msg: "optionnotfound",
|
||||
data: { objectPathname },
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -356,18 +352,18 @@ router.put(
|
||||
* @apiParam {string} tribe name (smatchit), where object is store
|
||||
* @apiParam {string} objectname object name where looking for
|
||||
* @apiBody {array} [apxid] list of apxid prefilter when for perfomance you want filter the search investigation. If omit then it is looking for in any item object
|
||||
* @apiBody {array} [fields] list of properties of object you want to get (profils user must have accessright in Read for those fields, a value 'unauthorized' can be return in this case)
|
||||
* @apiBody {string} [question] a specific syntaxe to find quickly items by using index litteral text @TODO : create a query syntaxe for a question...
|
||||
* @apiBody {array} [fields] string "all" or list of properties of object you want to get (profils user must have accessright in Read for those fields, a value 'unauthorized' can be return in this case)
|
||||
* @apiBody {string} [condition] an array of condition {propertieA:[value1,value2],propertieB:[valu9],function:["name1",name2],...} select objectname id that match proprieteA = valu1 or value2 AND proprieteB=valu9 AND function name1(object) return true AND function name2(object) function are string code into schema @TODO ...
|
||||
*
|
||||
* @apiSuccess {json} contain {status,ref,msg,data}
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* HTTP/1.1 200 OK from {apxid:[itmid],fields:[field1,field2]}
|
||||
* @apiSuccessExample {json} Return objects per id
|
||||
* HTTP/1.1 200 OK from body {apxid:[itmid],fields:[field1,field2]}
|
||||
* {"status":200, "ref":"Odmdb", "msg":"searchresult", "data":{"itms":{itmid:{field1,field2}]}}
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* HTTP/1.1 200 OK from {question:}
|
||||
* @apiSuccessExample {json} Return arrays of ids
|
||||
* HTTP/1.1 200 OK from {question:[{"color":['blue','red']},{size:["<100"]},{function:name}]}
|
||||
* {"status":200, "ref":"Odmdb", "msg":"searchresult", "data":[itm1,itm2]}
|
||||
* @apiError {json} objectdoesnotexist the obbject does not exist for the tribe
|
||||
* @apiError {json} unconsistentquestion the question format is not relevant
|
||||
* @apiError {json} objectdoesnotexist the obbject does not exist for the tribe
|
||||
* @apiError {json} unconsistentcondition condition format is not relevant
|
||||
* @apiErrorExample {json}
|
||||
* HTTP/1.1 404 Not Found
|
||||
* {"status":404,"ref":"Odmdb","msg":"templatestring Odmdb_xx.json","data":"object to render with msg"}
|
||||
@@ -415,14 +411,20 @@ router.get(
|
||||
const objectpath = `../../${req.params.tribe}/objects/${req.params.objectname}/itm/${req.params.primaryindex}.json`;
|
||||
|
||||
if (fs.existsSync(objectpath)) {
|
||||
res
|
||||
.status(200)
|
||||
.json({
|
||||
status: 200,
|
||||
ref: "Odmdb",
|
||||
msg: "itmfound",
|
||||
data: fs.readJsonSync(objectpath),
|
||||
});
|
||||
const readobj = Odmdb.r(
|
||||
`../../${req.params.tribe}/objects/${req.params.objectname}`,
|
||||
req.params.primaryindex,
|
||||
{
|
||||
xprofils: req.session.header.xprofils,
|
||||
xalias: req.session.header.xalias,
|
||||
}
|
||||
);
|
||||
res.status(200).json({
|
||||
status: 200,
|
||||
ref: "Odmdb",
|
||||
msg: "itmfound",
|
||||
data: fs.readJsonSync(objectpath),
|
||||
});
|
||||
} else {
|
||||
res.status(404).json({
|
||||
status: 404,
|
||||
|
Reference in New Issue
Block a user