Queuing order for db:add
Hi Marco,
Quoted text · Marco Lettere · 2 lines
> Does db:add multiple resources to the same path guarantee sorting based > on insertion time?
Sorry for the late reply, but I’m not sure if I understand your question. It’s correct, it’s possible to add multiple resources to the same path, e.g. as follows:
for $i in 1 to 100
return db:add('db', <a/>, 'a.xml')There’s no need to do any sorts, as the target path is identical. All resources will simply be attached to the database storage.
Or did you question yourself if sorting is some necessary when resources are requested in a later step?
Ciao, Christian
Hi Christian,
sorry for not being clear enough.
I was just wondering whether I can rely on insertion order being kept when I perform a corresponding db:get("db", "a.xml"). In other words given your slightly modified example:
for $i in 1 to 100
return db:add('db', <a x="{$i}"/>, 'a.xml')Will
db:get('db','a.xml')always return
(<a x="1"/>, <a x="2"/>, ...<a x="100"/>)
M.
Quoted text · Christian Grün · 20 lines
On 11/04/23 09:03, Christian Grün wrote: > Hi Marco, > >> Does db:add multiple resources to the same path guarantee sorting based >> on insertion time? > Sorry for the late reply, but I’m not sure if I understand your > question. It’s correct, it’s possible to add multiple resources to the > same path, e.g. as follows: > > for $i in 1 to 100 > return db:add('db', <a/>, 'a.xml') > > There’s no need to do any sorts, as the target path is identical. All > resources will simply be attached to the database storage. > > Or did you question yourself if sorting is some necessary when > resources are requested in a later step? > > Ciao, > Christian
Quoted text · Marco Lettere · 2 lines
> I was just wondering whether I can rely on insertion order being kept > when I perform a corresponding db:get("db", "a.xml").
Thanks. Yes, you can!
Written for BaseX 10.5. BaseX may have changed since: please check the current documentation.