Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store.add does not work as documented #323

Open
nichtich opened this issue Feb 14, 2023 · 0 comments
Open

Store.add does not work as documented #323

nichtich opened this issue Feb 14, 2023 · 0 comments

Comments

@nichtich
Copy link

Storing as documented:

#!/usr/bin/env node

const N3 = require('n3')
const { DataFactory } = N3
const { namedNode, literal, defaultGraph, quad } = DataFactory

const store = new N3.Store()
store.add(
  namedNode('http://ex.org/Pluto'),
  namedNode('http://ex.org/type'),
  namedNode('http://ex.org/Dog')
)
store.add(
  namedNode('http://ex.org/Mickey'),
  namedNode('http://ex.org/type'),
  namedNode('http://ex.org/Mouse')
)

// Retrieve all quads
for (const quad of store)
  console.log(quad);

console.log(store.size)

results in this output

Quad {
  id: '',
  _subject: DefaultGraph { id: '' },
  _predicate: DefaultGraph { id: '' },
  _object: DefaultGraph { id: '' },
  _graph: DefaultGraph { id: '' }
}
1

I don't understand the details of store.add vs. store.addQuad but the latter works:

store.addQuad(quad(
  namedNode('http://ex.org/Pluto'),
  namedNode('http://ex.org/type'),
  namedNode('http://ex.org/Dog')
))
store.addQuad(quad(
  namedNode('http://ex.org/Mickey'),
  namedNode('http://ex.org/type'),
  namedNode('http://ex.org/Mouse')
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant