Skip to content

Commit b23c439

Browse files
committed
[Feature] WOQL.insert_data: multiple values per property #31
1 parent 2274498 commit b23c439

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

lib/query/woqlBuilder.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ WOQLQuery.prototype.property = function(proId, type_or_value) {
140140
return this
141141
}
142142

143-
144143
WOQLQuery.prototype.node = function(node, type) {
145144
type = type || false
146145
if (type == 'add_quad') type = 'AddQuad'
@@ -170,22 +169,41 @@ WOQLQuery.prototype.insert_data = function(data, refGraph) {
170169
type = this.cleanType(data.type, true)
171170
this.insert(data.id, type, refGraph)
172171
if (data.label) {
173-
this.label(data.label)
172+
console.log(data.label)
173+
if (Array.isArray(data.label)) {
174+
data.label.forEach(value => {
175+
this.label(value)
176+
})
177+
} else {
178+
this.label(data.label)
179+
}
174180
}
175181
if (data.description) {
176-
this.description(data.description)
182+
if (Array.isArray(data.description)) {
183+
data.description.forEach(value => {
184+
this.description(value)
185+
})
186+
} else {
187+
this.description(data.description)
188+
}
177189
}
178190
for (var k in data) {
179191
if (['id', 'label', 'type', 'description'].indexOf(k) == -1) {
180-
this.property(k, data[k])
192+
if (Array.isArray(data[k])) {
193+
data[k].forEach(value => {
194+
this.property(k, value)
195+
})
196+
} else {
197+
this.property(k, data[k])
198+
}
181199
}
182200
}
183201
}
184202
return this
185203
}
186204

187205
/**
188-
* @description Creates a pattern matching rule for a quad [Subject, Predicate, Object, Graph] or for a triple [Subject, Predicate, Object]
206+
* @description Creates a pattern matching rule for a quad [Subject, Predicate, Object, Graph] or for a triple [Subject, Predicate, Object]
189207
* add extra information about the type of the value object
190208
* @param {string} subject - The IRI of a triple’s subject or a variable
191209
* @param {string} predicate - The IRI of a property or a variable
@@ -379,10 +397,10 @@ WOQLQuery.prototype._string_matches_object = function(str, node) {
379397
}
380398

381399
/**
382-
*
383-
* @param {string} n
400+
*
401+
* @param {string} n
384402
* @param {string} which
385-
* @returns {WOQLQuery}
403+
* @returns {WOQLQuery}
386404
*/
387405

388406
WOQLQuery.prototype._card = function(n, which) {

0 commit comments

Comments
 (0)