Skip to content

Commit

Permalink
add GET /resource/:iri/property/:piri/value
Browse files Browse the repository at this point in the history
  • Loading branch information
na57 committed May 23, 2024
1 parent e862bfe commit 396fa2b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "triples-api",
"version": "1.8.1",
"version": "1.9.0",
"description": "对triples进行操作的Restful API",
"main": "index.js",
"type": "module",
Expand Down
12 changes: 12 additions & 0 deletions src/rdf/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,19 @@ export const setAnnotations = async (req, res) => {
});
}

const getPropertyValues = async (req, res) => {
const { piri } = req.params;
const resource = res.resource as IRdfsResource;
const vs = await resource.getPropertyValues(piri);
console.log('vs::', vs);
const data = await Promise.all(vs.map(v => v.getAnnotations()));
res.json({
data,
});
}

router.get('/:iri', getOrCreateResource, getAnnotations);
router.put('/:iri', getOrCreateResource, setAnnotations);
router.post('/:iri', getOrCreateResource, setAnnotations);
router.get('/:iri/property/:piri/value', getOrCreateResource, getPropertyValues);
export default router;

0 comments on commit 396fa2b

Please sign in to comment.