Comments (8)
Hi @apppro123
-
It will need 2 inserts, for
Calendar
andCalendarEvents
. Besides, Vasern will automatically create anid
(lowercase) field.
(P/s: Custom id has not available yet, you won't needID
in your schema)Here is an example, with adding reference object:
var insertedCalendars = Calendar.insert({ Title:"CalendarExample", Color:"#FFFFFF" }); // Calendar.insert will return an array of objects will be inserted into database with generated id. // For example: // insertedCalendars = [ // { id: 'a_random_unique_id', Title: "CalendarExample", Color:"#FFFFFF" } // ] var insertedEvents = CalendarEvents.insert({ Title: "example", Start: startTime, End: endTime, Calendar: insertedCalendars[0] // or insertedCalendars[0].id - reference by `id` or actual object });
-
Property with
datetime
will takes either aDate
object or a time value in milliseconds. If you useMomentjs
, I think you can use.valueOf()
to get time in milliseconds. Though,datetime
is not timezone aware.
from vasern.
You have used insertedCalendars[0] in insertedEvents under Calendar: Is it possible to insert objects? Or is it just possible to insert insertedCalendars[0].id?
And is every generated id unique for this element?
from vasern.
I'm a bit confuse about the question, pls let me know if my answer isn't what you are looking for.
-
Yes, it's possible to insert an array of reference
Calendar
objects toCalendarEvents
. But the schema needs to be changed to:var calendarEventSchema = { name: "CalendarEvents", props: { ..., Calendars: "[]#Calendar" // [] means list } }
Then you can pass the array of inserted objects like:
var insertedEvents = CalendarEvents.insert({ Title: "example", Start: startTime, End: endTime, Calendar: insertedCalendars });
-
id
generator was inspired with MongoDB ObjectID design, which is highly unique. Though,this element
is not uniqued. Currently, to make sure an element is unique, you need to check in the database first (usingfilter
). Sounds like a necessary feature for the upcoming version, I'll take note of this.
Just a head ups, data types will be updated in the next version, so "[]#Calendar" will be deprecated or invalid soon. Also, using lowercase for property name is more preferable.
from vasern.
Thank you first.
So is it possible to insert an object into an element of the db? I just need one Calendar for one event.
And ty for the tip with lowercase characters.
from vasern.
You're welcome. Yes, you can pass either a Calendar
object or its id
to CalendarEvents
as
// it will automatically get and replace the `id` from `insertedCalendars[0]`
Calendar: insertedCalendars[0]
from vasern.
Ok thanks!
from vasern.
No worries!
from vasern.
I will close this issue since it has been resolved. Also, feel free to reopen or create a new one again
from vasern.
Related Issues (20)
- is this still in active development? HOT 4
- broken data on load app HOT 8
- insert not work HOT 2
- Is it stable enough for production HOT 3
- I want to know how to save the server API data from the location with vasern, I can't see more details in the documentation HOT 3
- Data is not updated when saving HOT 1
- does vasern supported Bulk Insert? HOT 11
- Error when linking HOT 2
- Slack link is not working anymore HOT 2
- Relationship table HOT 4
- React Native Bridge -> JSI
- Queryable limit
- Functions names
- C++ business logic
- Queryable events
- Insertion problem HOT 3
- Support default Value? HOT 8
- Feature: Encryption option HOT 8
- Numbers inserted as strings HOT 2
- Broken Links in Getting Started Section HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vasern.