CRUD operations for Posts
- added all CRUD operations for Post model - add() also creates POST_BY_MEMBER and POST_FROM_NETWORK edges - delete() also deletes associated edges - delete() currently does not reallocate node/edge indices after deleting - will write the data to the db.json file and global.db.nodes
This commit is contained in:
@@ -1,13 +1,21 @@
|
||||
export default class Edge {
|
||||
add(n) {
|
||||
splitEdge(n) {
|
||||
let toPrefix = n.to.split("-")[0]
|
||||
let fromPrefix = n.from.split("-")[0]
|
||||
let type = n.type
|
||||
let prefix = `${fromPrefix}_${type}_${toPrefix}`
|
||||
return `${fromPrefix}_${type}_${toPrefix}`
|
||||
}
|
||||
|
||||
add(n) {
|
||||
let prefix = this.splitEdge(n)
|
||||
global.db.addEdge(prefix, n)
|
||||
}
|
||||
|
||||
delete(n) {
|
||||
let prefix = this.splitEdge(n)
|
||||
global.db.deleteEdge(prefix, n.from.split("-")[1])
|
||||
}
|
||||
|
||||
getByFrom(fromID) {
|
||||
let result = []
|
||||
for(let i = 0; i < this.entries.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user