0

I'm writing cordova + angular + breeze app where text info from element should be stored in the cash of browser that wraps the app. Accordind to the docs to do so, first I need to create new entity type in breeze. I do the following:

var entityManager = new breeze.EntityManager("api/Northwind");
var newType = new breeze.EntityType({
    shortName: "input"
});

Next I'm trying to create new entity of this type:

var newEntity = newType.createEntity();

This fails with message: "TypeError: Cannot read property '_ctorRegistry' of undefined"

Is seems to be very basic functionality of breeze but I can't get it work for 2 days already. Could anyone help me with that?

1
  • As the accepted answer indicates, there are at least 3 problems here. (1) the new type must be added to a MetadataStore ... almost certainly the one that belongs to the manager (manager.metadataStore) and (2) the new type should have some properties ... at least a key property. Now Breeze will think you can persist this to the server so you better guard against that. I find myself wondering "Why is Qvatra creating a pretend entity that can't be persisted?". You may have a good reason but it seems a dubious move on it face. Commented May 16, 2014 at 22:55

1 Answer 1

1

After created new EntityType, you should attach it to metadataStore to create entities of new type. Your code should look:

var metadataStore = new breeze.MetadataStore();
entityManager= new breeze.EntityManager({
            serviceName: "api/db",
            metadataStore: metadataStore
        });

// if you call fetchMetadata()
entityManager.fetchMetadata().then(function(){
    var newType = new breeze.EntityType({
        shortName: "input"
    });

    entityManager.metadataStore.addEntityType(newType);

    newType.createEntity(...);
    // ...
});

//or just use var metadataStore
var newType = new breeze.EntityType({
    shortName: "input"
});

entityManager.metadataStore.addEntityType(newType);

newType.createEntity(...);
// ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.