Reputation: 69
This is my Schema for a Message history i'm getting from the API
export default class MessageSchema {
static schema = {
name: 'MessagesHistory',
primaryKey: '_id',
properties: {
_id: 'string',
text: 'string',
createdAt: 'string',
user: {
uname: 'string',
name: 'string',
_id: 'string',
avatar: 'string',
rid: 'string',
},
},
};
}
and this is my Realm Function
import Realm from 'realm';
import ChatlistSchema from './ChatlistSchema';
import MessageSchema from './MessageSchema';
export default function getRealm() {
return Realm.open({
schema: [ChatlistSchema, MessageSchema],
});
}
Whenever I try to add the MessagesSchema to the Schema array, it gives me a promise rejection, and the data from the ChatlistChema object isn't loading also.
*Error: type must be of type 'string', got (undefined)
[native code]*
............
Does anyone know what I'm doing wrong?
Upvotes: 1
Views: 2979
Reputation: 1101
I had changed the schema sometime back (which I completely forgot) due to which I was facing this issue.
Upvotes: 0
Reputation: 403
I had this error differently (got (0)
) and the cause was there were some errors in a schema class. Some properties had a value 0 assigned instead of the data type name (double).
Upvotes: 1