OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Is there a way to define field types for Parse Objects?

  • Thread starter Thread starter Ali
  • Start date Start date
A

Ali

Guest
I am using Parse Server and Parse JS SDK to develop an application. I recently started using typescript for my project. The question is, Can I define field types for Parse Objects?

For example, I have defined a Parse object for a post, and I want it to have a title field of type string

Code:
const Post = Parse.Object.extend("Post");

First of all I don't understand why the type of Post is any

Secondly, I want the following code to throw an error or warning:

Code:
const post = new Post();
post.set("title", 123) // title should be a string and not a number

How can I do this? Thanks

I have searched parse github and the internet for hours and found nothing. I have tried experimenting with the second and third argument of the extend function. But I couldn't figure it out. I don't know if it is related to what I am trying to do or not.

<p>I am using Parse Server and Parse JS SDK to develop an application. I recently started using typescript for my project. The question is, Can I define field types for Parse Objects?</p>
<p>For example, I have defined a Parse object for a post, and I want it to have a <code>title</code> field of type <code>string</code></p>
<pre><code>const Post = Parse.Object.extend("Post");
</code></pre>
<p>First of all I don't understand why the type of <code>Post</code> is <code>any</code></p>
<p>Secondly, I want the following code to throw an error or warning:</p>
<pre><code>const post = new Post();
post.set("title", 123) // title should be a string and not a number
</code></pre>
<p>How can I do this?
Thanks</p>
<p>I have searched parse github and the internet for hours and found nothing.
I have tried experimenting with the second and third argument of the <code>extend</code> function. But I couldn't figure it out. I don't know if it is related to what I am trying to do or not.</p>
 

Latest posts

S
Replies
0
Views
1
Safwan Aipuram
S
Top