Will that pin the DO to memory while the stub is being 'used'?
Will that pin the DO to memory while the stub is being 'used'?
Indexes will add an additional written row when writes include the indexed column, as there are two rows written: one to the table itself, and one to the index.
list({prefix: 'pre-')list() order is always lexicographical and there's no way to limit the list, but there's also https://developers.cloudflare.com/durable-objects/api/storage-api/#list which includes options such as limit and reverse ...can these all be used together with list({prefix: 'pre-') from the KV API?list() in DO KV returns the K:V pairs, whereas Workers KV only returns the key names (can Workers KV be changed to align with DO KV?? This is such a weird distinction between the two)
By writing a Durable Object class which inherits from the built-in type DurableObject, public methods on the Durable Objects class are exposed as RPC methods, which you can call using a DurableObjectStub from a Worker.
wrangler.yml and added a deleted_classes migration, but it still complained about worker binding not removed.this.state.acceptWebSocket(socket) instead of socket.accept() to avoid massive chargesstorage.put() multiple times without awaiting, it will group all the writes into a single round trip. If you put to the same key multiple times without awaiting, will it write to that key multiple times or will it only write the last one?env, you need to pass them in your RPC call to the DO.constructor, I might make an init method so I don't have to pass it on every call
init(uid) the first time the user object is created, save the user's id to storage, and this way it will be available in storage whenever I'm calling that DO again, right? Just need to set it in the constructor like this:[[durable_objects.bindings]]
# This is the name of the binding that will be availble in our worker
name = "CHATROOM"
class_name = "Chatroom"const roomName1 = 'unique room name 1'
env.CHATROOM.idFromName(roomName1);const roomName2 = 'unique room name 2'
env.CHATROOM.idFromName(roomName2);list({prefix: 'pre-')list({prefix: 'pre-')list()list()limitreversewrangler.ymldeleted_classes```this.state.acceptWebSocket(socket)socket.accept()storage.put()putenvconstructorconstructorinitinit(uid)app.get('/avatars', async c => {
const user = c.get('user')
c.env.uid = user.uid // is this a bad practice?
const userObjectId = c.env.USER_OBJECT.idFromName(user.uid)
const userObject = c.env.USER_OBJECT.get(userObjectId)
const avatars = await userObject.getAvatars()
return c.json(avatars)
})ctx.blockConcurrencyWhile(async () => {
this.uid = await ctx.storage.get('uid')
})