db:replace throwing error
Tuesday, 18 March 2014 · 3 messages
CG
Quoted text · Jesse Clark · 2 lines
> However, when I try to run a query using db:replace: > return db:replace($database, $jsonXML, $targetProfilePath)
You'll probably need to swap the second and third argument; see [1]. I agree it's confusing that the signatures for
db:add() and db:replace() differ. This is due to backward compatibility issues, and may be fixed with a future db:update() function that will combine the functionality of both db:add() and db:replace().
[1] http://docs.basex.org/wiki/Database_Module#db:replaceQuoted text · Jesse Clark · 24 lines
> > > I get the following error regardless of whether there is a document in the > db at that path or not: > [FODC0002] Resource "/targetProfiles/5321cff2e4b0372d556893f4" does not > exist. > > db:add() seems to be working fine but I would prefer not to add multiple > documents at the same path. > > I suppose I can work around this by first using db:delete() to remove any > documents at the path and then using db:add() but I would appreciate any > insight into why db:replace() isn't working as expected. > > Thanks, > -Jesse > > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
JC
Jesse Clark18 Mar 2014 01:46 #
Hi All,
The module docs for db:replace (http://docs.basex.org/wiki/Database_Module#db:replace) states that: "Replaces a document, specified by $path, in the database $db with the content of $input, or adds it as a new document."
However, when I try to run a query using db:replace:
return db:replace($database, $jsonXML, $targetProfilePath)
I get the following error regardless of whether there is a document in the db at that path or not: [FODC0002] Resource "/targetProfiles/5321cff2e4b0372d556893f4" does not exist.
db:add() seems to be working fine but I would prefer not to add multiple documents at the same path.
I suppose I can work around this by first using db:delete() to remove any documents at the path and then using db:add() but I would appreciate any insight into why db:replace() isn't working as expected.
Thanks,
-JesseJC
Ahah! Good catch!
I did not expect the method signatures to be different and just changed the method name in my code when switching from add() to replace().
Thanks,
-Jesse
Quoted text · Christian Grün · 37 lines
On Mar 17, 2014, at 4:59 PM, Christian Grün <christian.gruen at gmail.com> wrote: >> However, when I try to run a query using db:replace: >> return db:replace($database, $jsonXML, $targetProfilePath) > > You'll probably need to swap the second and third argument; see [1]. I > agree it's confusing that the signatures for db:add() and db:replace() > differ. This is due to backward compatibility issues, and may be fixed > with a future db:update() function that will combine the functionality > of both db:add() and db:replace(). > > [1] http://docs.basex.org/wiki/Database_Module#db:replace > > >> >> >> I get the following error regardless of whether there is a document in the >> db at that path or not: >> [FODC0002] Resource "/targetProfiles/5321cff2e4b0372d556893f4" does not >> exist. >> >> db:add() seems to be working fine but I would prefer not to add multiple >> documents at the same path. >> >> I suppose I can work around this by first using db:delete() to remove any >> documents at the path and then using db:add() but I would appreciate any >> insight into why db:replace() isn't working as expected. >> >> Thanks, >> -Jesse >> >> >> >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>
Written for BaseX 7.8. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery