Problem to $persist
See original GitHub issueI dont know why I cant persist and object… I got: fetch, push and destroy works well.
vuex-orm-graphql.es5.js?8eb2:1 Uncaught (in promise) TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at Function.e.transformOutgoingData (vuex-orm-graphql.es5.js?8eb2:1)
at Function.e.addRecordToArgs (vuex-orm-graphql.es5.js?8eb2:1)
at Function.eval (vuex-orm-graphql.es5.js?8eb2:1)
at eval (vuex-orm-graphql.es5.js?8eb2:1)
at Object.eval [as next] (vuex-orm-graphql.es5.js?8eb2:1)
at eval (vuex-orm-graphql.es5.js?8eb2:1)
at new Promise (<anonymous>)
at __awaiter (vuex-orm-graphql.es5.js?8eb2:1)
at Function.t.call (vuex-orm-graphql.es5.js?8eb2:1)
Sector,js
import { Model } from '@vuex-orm/core'
export default class Sector extends Model {
static entity = 'sectors'
static fields () {
return {
id: this.number(null),
name: this.string(''),
}
}
}
store/index.js
import Vue from 'vue';
import Vuex from 'vuex';
import VuexORM from '@vuex-orm/core';
import VuexORMGraphQL from '@vuex-orm/plugin-graphql';
import { AuthModule } from './auth-module';
import { HttpModule } from './http-module';
import { SettingsModule } from './settings-module';
import { CustomAdapter } from '@/plugins/graphql-adapter';
import ApolloClient from '@/plugins/apollo-client';
// Create a new instance of Database.
const database = new VuexORM.Database();
// Models
import User from '@/models/User';
import Sector from '@/models/Sector';
import Subsector from '@/models/Subsector';
import Segment from '@/models/Segment';
// Register Models to Database.
database.register(User);
database.register(Sector);
database.register(Subsector);
database.register(Segment);
VuexORM.use(VuexORMGraphQL, {
database,
adapter: new CustomAdapter(),
apolloClient: ApolloClient
});
Vue.use(Vuex);
export default new Vuex.Store({
plugins: [VuexORM.install(database)],
modules: {
auth: AuthModule,
http: HttpModule,
settings: SettingsModule
},
});
Sector.vue
<script>
import Sector from '@/models/Sector';
export default {
data() {
return {
sector: {},
}
},
async mounted() {
await Sector.fetch();
},
computed: {
sectors: () => Sector.all(),
},
methods: {
newf() {
this.sector = {};
},
edit(sector) {
this.sector = sector;
},
async create() {
await Sector.insert({data: this.sector});
const sector = Sector.query().last();
await sector.$persist();
},
async update() {
await this.sector.$push();
},
async destroy(sector) {
await sector.$deleteAndDestroy();
}
}
};
</script>
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
Problem persists definition and meaning - Collins Dictionary
Problem persists definition: If something undesirable persists , it continues to exist. [...] | Meaning, pronunciation, translations and examples.
Read more >If the problem still persists or If the problem still persist ?
The correct phrase is "If the problem still persists," because the word "problem" is singular, and the singular third-person form of the verb...
Read more >What does "Let me know if the problem persists" exactly mean?
A logician might say that the person being addressed need say anything only if the problem did persist. In practice, the context will...
Read more >The problem is persisting | English examples in context - Ludwig
The problem is that Carr persists in equating war against civilians with terrorism, and this leads to absurdity.
Read more >Five Things I Know About Solving Persistent Problems
If they had worked, the problem would no longer exist. Your solutions have now become part of the problem system. If you do...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am using string ids in many of my models. Hat to fork the Repo and remove all “toNumber” calls in the code. Hope it will be fixed soon
With generated
$id: "tyr13zqj"
I have the same errorUncaught (in promise) TypeError: Cannot convert undefined or null to object
.Seems that now (vuex-orm/core 0.36.3) it not prefixed with
$uid
in models:id: this.uid(() => tempId()) // tempId returns 'tyr13zqj' value
But in plugin code we have
where
toPrimaryKey
isWhy you need that conversion in plugin? Just return string if that is string!