xTMNTxRaphaelx
xTMNTxRaphaelx

Reputation: 1397

Datatype mismatch in Jaydata

I am managing offline db using jaydata + sqlite. In jaydata nvarchar(20) is not a valid datatype so I need to use 'String' as datatype. Online db is using datatype as nvarchar(20).

Now,my question is: Is it possible to map both offline db and online db because 'nvarchar(20)' is datatype on online db and 'string' is datatype on offline db' ??


This is what I am supposed to create in my online db:

enter image description here

This is what I have created in my offline db with jaydata+sqlite:


// Table definition of  user
$data.Entity.extend("user", {
    'UserId'        :  { key:true,type:'int',nullable:false,required:true  },
    'Username'      :  { type:'string',nullable:false,required:true },
    'Password'      :  { type:'string',nullable:false,required:true},
    'UserType'      :  { type:'string',nullable:false,required:true},
    'CreatorId'     :  { type:'int',nullable:false,required:true},
    'CreatedAt'     :  { type:'datetime',nullable:true},
    'ModifierId'    :  { type:'int',nullable:true},
    'ModidiedAt'    :  { type:'datetime',nullable:true},
    'IsDeleted'     :  { type:'boolean',nullable:false,required:true}
});

Upvotes: 0

Views: 115

Answers (1)

Peter Aron Zentai
Peter Aron Zentai

Reputation: 11740

disclaimer: I am one of the creators of JayData

You can use your online schema to create an offline database. NVarchar(20) is not even an OData type - so I guess it will just be 'Edm.String' with a maxLength=20 modifier. Edm.String is however mapped to the type "String" in JavaScript.

Sharing your schema definition would also help me giving better answers.

EDITED

The following schema definition would work with an online endpoint (provided with odata or REST) and would also create the same table definition locally.

$data.Entity.extend("user", {
    'userid'        :  { key:true,type:'string', maxLength:216,required:true  },
    'username'      :  { type:'string',maxLength:216, required:true },
    'password'      :  { type:'string',maxLength:64,required:true},
    ....
});

Is this what you needed? Please note that in JS every string is nvarchar since javascript is UTF8 internally.

Upvotes: 1

Related Questions