Skip to content

Commit 9cba6e8

Browse files
committed
fix id generator
1 parent 4af00fd commit 9cba6e8

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

app/volt/tasks/live_query/data_store.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def query(collection, query)
1212
query = query.dup
1313
query.keys.each do |key|
1414
if key =~ /_id$/
15-
query[key] = BSON::ObjectId(query[key])
15+
# query[key] = BSON::ObjectId(query[key])
1616
end
1717
end
1818

app/volt/tasks/store_tasks.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ def save(collection, data)
3737
errors = model_errors(collection, data)
3838

3939
if errors.size == 0
40+
# id = BSON::ObjectId(data[:_id])
4041
id = data[:_id]
4142

4243
# Try to create
4344
# TODO: Seems mongo is dumb and doesn't let you upsert with custom id's
4445
begin
46+
# data['_id'] = BSON::ObjectId('_id') if data['_id']
4547
@@db[collection].insert(data)
4648
rescue Mongo::OperationFailure => error
4749
# Really mongo client?

lib/volt/models/persistors/model_store.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Persistors
55
class ModelStore < Store
66
include StoreState
77

8-
ID_CHARS = [('a'..'z'), ('A'..'Z'), ('0'..'9')].map {|v| v.to_a }.flatten
8+
ID_CHARS = [('a'..'f'), ('0'..'9')].map {|v| v.to_a }.flatten
99

1010
attr_reader :model
1111
attr_accessor :in_identity_map
@@ -46,7 +46,7 @@ def add_to_identity_map
4646
# Create a random unique id that can be used as the mongo id as well
4747
def generate_id
4848
id = []
49-
12.times { id << ID_CHARS.sample }
49+
24.times { id << ID_CHARS.sample }
5050

5151
return id.join
5252
end

lib/volt/page/bindings/each_binding.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def item_added(position)
7878
def update_indexes_after(start_index)
7979
size = @templates.size
8080
if size > 0
81+
puts @templates.inspect
8182
start_index.upto(size-1) do |index|
8283
@templates[index].context.locals[:index].cur = index
8384
end

0 commit comments

Comments
 (0)