Store / Custom collection / Hilo in 4.x

99 views
Skip to first unread message

Nick

unread,
Mar 9, 2019, 11:27:22 AM3/9/19
to RavenDB - 2nd generation document database
Hi,

Before upgrading to 4.x, I had this to store a new entity:

Session.Store(campaign, "custom/campaigns/");

It was creating a new entity whose ID was using hilo, for instance custom/campaigns/65

But now in 4.x this creates an entity with ID custom/campaigns/0000000000000004022-A

How can I still use hilo and still specify a custom collection name? Note that I also use AsyncMultiTypeDatabaseHiloIdGeneratorWithoutNodeTag...

Thanks

Oren Eini (Ayende Rahien)

unread,
Mar 10, 2019, 3:57:18 AM3/10/19
to ravendb
That wasn't using hilo, actually, it was using identities behind the covers.

You can use postfix | for that, which will generate a (cluster wide) identity for you.

Alternatively, you can use the hilo directly when generating the id.


Session.Store(campain, myGenerator.Next())

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Oren Eini
CEO   /   Hibernating Rhinos LTD
Skype:  ayenderahien
Support:  sup...@ravendb.net

Nick

unread,
Mar 10, 2019, 10:53:10 AM3/10/19
to RavenDB - 2nd generation document database
Will use the pipe, thanks.

Note sure what this myGenerator thing is... some doc?

Oren Eini (Ayende Rahien)

unread,
Mar 10, 2019, 3:55:41 PM3/10/19
to ravendb
An instance of the hilo generator

Danielle Greenberg

unread,
Mar 12, 2019, 7:19:33 AM3/12/19
to rav...@googlegroups.com
Danielle Greenberg
Software Developer   /   Hibernating Rhinos LTD
Skype:  danielle.9897
Support:  sup...@ravendb.net

Nick

unread,
Mar 14, 2019, 5:31:02 PM3/14/19
to RavenDB - 2nd generation document database
I have used the pipe method and here is what I'm seeing:

I already have some old entities in this collection, some with ids ended by numbers from 15 to 30. Also some with ids like 0000000000000004022-A (see my previous message).
Since I use the pipe, the new entity is saved as custom/campaigns/1

As you can see it starts back at 1. What will it do when it encounters the existing ones at 15? Will it jump to 31?
Since it's not actually hilo but identities, how is the numbering controlled? Do I have control?

Thanks

Nick

unread,
Mar 14, 2019, 7:36:47 PM3/14/19
to RavenDB - 2nd generation document database
I got my answer. I continued my test by manually creating an entity with id custom/campaigns/2 in Studio.
Then I ran my web server to create a new campaign and it raised an exception saying that custom/campaigns/2 already existed (change vector, concurrency exception, bla bla bla).

Where is it said that it had to start at 2? I can't find any super document in Studio that manages this kind of property.... Can I indicate somewhere that it should continue at 31?

Arkadiusz Palinski

unread,
Mar 15, 2019, 4:49:08 AM3/15/19
to RavenDB - 2nd generation document database
Arkadiusz Paliński
Team Leader   /   Hibernating Rhinos LTD
Support:  sup...@ravendb.net
  

Nick

unread,
Mar 15, 2019, 8:20:40 AM3/15/19
to RavenDB - 2nd generation document database
1. Do I use this only once?
2. Is the new seed stored somewhere on the server?
3. Not displayed in Studio?
4. Is this command available in CLI so that I don't have to modify my server code to call this?

Oren Eini (Ayende Rahien)

unread,
Mar 17, 2019, 5:36:46 AM3/17/19
to ravendb
1) Yes
2) Yes
3) You can look it up using: http://live-test.ravendb.net/databases/DB_NAME/debug/identities there is no Studio UI for it.
4) Yes, POST /databases/*/identity/seed which you can call via curl

Nick

unread,
May 26, 2021, 3:06:47 PM5/26/21
to RavenDB - an awesome database
In latest ravendb, is this hilo value still hidden and not accessible/resettable in Studio?

Egor Shamanaev

unread,
May 27, 2021, 4:04:03 AM5/27/21
to rav...@googlegroups.com
Hi 

You can see it on the database stats page:
image.png

You received this message because you are subscribed to the Google Groups "RavenDB - an awesome database" group.

To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.


--
Egor

Developer   /   Hibernating Rhinos LTD
Support:  sup...@ravendb.net
  
Reply all
Reply to author
Forward
0 new messages