Vuex Normalized + VueDraggable - vue.js

I'm using vuedraggable and vuex in a project. I'm trying to normalize my vuex state by flattening it (to make it easier/faster to update data within it). This has forced me to change the state of my array of objects to an object of objects (so ID's can be the pointer/index of the objects themselves).
Is it possible to point vuedraggable at an object of objects instead of an array of objects so vuex normalization of state can be utilized, (e.g. the ID of the sub object can be the "index" of that object as well)? Or, if not, can an array be normalized by assigning the keys of the array to the ID of the objects within it instead of indexed numerically?

Related

IndexedDB using an index versus a key range?

In indexedDB, if the keys are arrays of integers such as [n,0] through [n,m], for operations that involve getting all the records in which the first element of the array key is n or opening a cursor on the same set of records, is there any advantage to using an index on an additonal property that stores n over using a key range?
Reasons to think an index may not be better include that the browser has to maintain the index for each change to the object store, an additional property has to be added to each record to store already stored data n, and little may be gained since the keys in the index will always point to consecutive records in the object store rather than dispersed throughout.
If the number of different values of n are likely no more than 1,000 and for m no more than 50, is using an index superior to a key range?
Thank you.
I guess the purpose of indexedDB is to have object store locally.
It is not sql that you need to update columns in every object.
since you change the object structure (saying by adding property)
it is true that all the objects in the store must be rewriten as you said...
emm well... another option for you is to update the db with another store
which contain somthing similar to forien key in sql or uniqe key which store the other stored objects extentions... and in it every obj item is also supposed to be same structured.
I think this is the point you start to use onupgradeneeded intansively.

How is idProperty used for more complex schema? Dojo dmodel

It’s not very clear how idProperty is used in the data store when building a data model. The documentation says “If the store has a single primary key, this indicates the property to use as the identity property. The values of this property should be unique. This defaults to "id".
Is this assuming the schema from which the model is based, has a mostly flat structure? For example an array of objects – each with an identity property?
What if the schema is not a simple array but has more complex structure starting from a single object that contains several sub levels of properties within properties. OR is just multiple arrays on the same level where each group of arrays identify property are independent of one another?
A store is an extension of a collection.
A collection is the interface for a collection of items (your obect with a potentially complex schema).
You can use Custom Querying on a collection to define special queries to find your data with any subset of properties.
In short, yes you can querying your data even if it has a custom schema but you need to define a Custom Querying.
More info can be found here at the end of the article: https://github.com/SitePen/dstore/blob/master/docs/Collection.md

KVO - copying observed object

I'd like to be sure about something.
Suppose I have a NSArray, with some objects.
Suppose that those objects are observed.
Now, if I create another NSArray with the first one (initWithArray:copyItems:NO), will the observation be untouched ?
And if I create with copying (initWithArray:copyItems:YES), will the observation follow the new objects in the new array ?
Thanks !
The observation is linked to the original objects by their pointers.
If you create a new array without copying then the objects are the same. The observation doesn't change, you just have multiple references to the same objects.
If you create a new array with copying then the objects are different but the original objects still exist in the original array. The observation doesn't change, you are still observing the original objects. The new objects are effectively unrelated and have no observers.

What is a Dictionary of Arrays in OOP?

In the context of OOP, what is the name (or class name) of a data structure composed of a Dictionary of Arrays?
(a Dictionary where each key is mapped to a collection of values)
In the case you cannot find a class representing this data structure, what would be a proper name for this object?
I came from http://en.wikipedia.org/wiki/List_of_data_structure but the most similar I've found is http://en.wikipedia.org/wiki/Multimap which it seems to me that is wrong because the article talks about cardinality and I don't care about that.
I believe that it is usually just called a Dictionary of Arrays. ;) Usually you don't need a special data structure, you just have a dictionary that has references to Arrays as values.

Nhibernate bag collection when is it re-creating?

I made a lot of examples to check when bag collection is recreating during adding or removing item from collection. I read that in http://knol.google.com/k/nhibernate-chapter-16-improving-performance section 16.5.1. Taxonomy:
Bags are the worst case. Since a bag
permits duplicate element values and
has no index column, no primary key
may be defined. NHibernate has no way
of distinguishing between duplicate
rows. NHibernate resolves this problem
by completely removing (in a single
DELETE) and recreating the collection
whenever it changes. This might be
very inefficient.
I made bidirectional of type one to many(Person -> Addresses) and the following tests:
Test 1: Inverse= false; action=insert,update,remove,count; Collection types: Set, Bag
Result: Collections behave exactly the same!
Test 2: Inverse= true; action=insert,update,remove,count; Collection types: Set, Bag
Result: Collections behave almost the same! I only see difference in adding new item to bag collection - when i do that collection is not filled with data from db.
I was using nhibernate profiler/session statystics for analizying changes in session object and in database. But i did not see any recreating items of collection, whed did it happend? i memory?
Recreating collections applies only for entities loaded from the database. When running tests in the same session that the entities were created, NHibernate knows that the collections are empty, manipulates it in memory and saves only the final state to the database on transaction commit/session flush.
I've done similiar tests - see this blog entry for example of re-creating bag collection.